Zelda Classic Coverage Report


Directory: src/
File: src/zc/ffscript.cpp
Date: 2023-08-19 11:15:58
Exec Total Coverage
Lines: 5057 24418 20.7%
Functions: 287 1041 27.6%
Branches: 2988 19244 15.5%

Line Branch Exec Source
1 #include <deque>
2 #include <string>
3 #include <sstream>
4 #include <math.h>
5 #include <cstdio>
6 //
7 #include <sys/types.h>
8 #include <sys/stat.h>
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include <fstream>
12 #include <filesystem>
13 #include <fmt/format.h>
14 //
15
16 #include "base/qrs.h"
17 #include "base/dmap.h"
18 #include "base/msgstr.h"
19 #include "base/packfile.h"
20 #include "base/misctypes.h"
21 #include "zc/zc_sys.h"
22 #include "zc/jit.h"
23 #include "zc/script_debug.h"
24 #include "base/zc_alleg.h"
25 #include "base/zc_math.h"
26 #include "base/zc_array.h"
27 #include "zc/ffscript.h"
28 #include "zc/render.h"
29 #include "zc/zc_subscr.h"
30 #include <time.h>
31 #include "zc/script_drawing.h"
32 #include "base/util.h"
33 #include "zc/ending.h"
34 #include "base/module.h"
35 #include "zc/combos.h"
36 #include "drawing.h"
37 #include "base/colors.h"
38 #include "pal.h"
39 #include "zinfo.h"
40 #include <sstream>
41
42 #ifdef _WIN32
43 #define SCRIPT_FILE_MODE (_S_IREAD | _S_IWRITE)
44 #else
45 #include <fcntl.h>
46 #include <unistd.h>
47 #include <iostream>
48 #define SCRIPT_FILE_MODE (S_ISVTX | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)
49 #endif
50
51 //Define this register, so it can be treated specially
52 #define NUL 5
53 #define MAX_ZC_ARRAY_SIZE 214748
54
55 // #define _SCRIPT_COUNTER
56
57 #ifdef _SCRIPT_COUNTER
58 static int64_t script_timer[NUMCOMMANDS];
59 static int64_t script_execount[NUMCOMMANDS];
60 #endif
61
62 using namespace util;
63 using std::ostringstream;
64
65 extern byte use_dwm_flush;
66 uint8_t using_SRAM = 0;
67
68 extern zinitdata zinit;
69 int32_t hangcount = 0;
70 bool can_neg_array = true;
71
72 extern byte monochrome_console;
73
74 230 static std::set<int> seen_scripts;
75 115 static std::map<int, ScriptDebugHandle> script_debug_handles;
76 ScriptDebugHandle* runtime_script_debug_handle;
77 115 static std::map<std::pair<script_data*, refInfo*>, JittedScriptHandle*> jitted_scripts;
78 int32_t jitted_uncompiled_command_count;
79
80 115 CScriptDrawingCommands scriptdraws;
81 115 FFScript FFCore;
82 ZModule zcm;
83 zcmodule moduledata;
84 115 script_bitmaps scb;
85
3/4
✓ Branch 0 taken 29440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29325 times.
✓ Branch 3 taken 115 times.
29440 user_file script_files[MAX_USER_FILES];
86
3/4
✓ Branch 0 taken 29440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29325 times.
✓ Branch 3 taken 115 times.
29440 user_dir script_dirs[MAX_USER_DIRS];
87
3/4
✓ Branch 0 taken 24696020 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24695905 times.
✓ Branch 3 taken 115 times.
24696020 user_object script_objects[MAX_USER_OBJECTS];
88
3/4
✓ Branch 0 taken 29440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29325 times.
✓ Branch 3 taken 115 times.
29440 user_stack script_stacks[MAX_USER_STACKS];
89 115 user_rng nulrng;
90 115 user_rng script_rngs[MAX_USER_RNGS];
91 115 zc_randgen script_rnggens[MAX_USER_RNGS];
92 user_paldata script_paldatas[MAX_USER_PALDATAS];
93
94 FONT *get_zc_font(int index);
95
96 int32_t combopos_modified = -1;
97 static word combo_id_cache[7*176] = {0};
98
99 57344 void user_dir::clear()
100 {
101 57344 filepath = "";
102 57344 reserved = false;
103 57344 owned_type = (ScriptType)-1;
104 57344 owned_i = 0;
105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57344 times.
57344 if(list)
106 {
107 list->clear();
108 free(list);
109 list = NULL;
110 }
111 57344 }
112 void user_dir::setPath(const char* buf)
113 {
114 if(!list)
115 {
116 list = (FLIST *) malloc(sizeof(FLIST));
117 }
118 reserved = true;
119 filepath = std::string(buf) + "/";
120 regulate_path(filepath);
121 list->load(filepath.c_str());
122 }
123
124 int32_t CScriptDrawingCommands::GetCount()
125 {
126 al_trace("current number of draws is: %d\n", count);
127 return count;
128 }
129 //Advances the game frame without checking 'Quit' variable status.
130 //Used for making scripts such as Player's onWin and onDeath scripts
131 //run for multiple frames.
132
133 void FFScript::Waitframe(bool allowwavy, bool sfxcleanup)
134 {
135 if(zcmusic!=NULL)
136 {
137 zcmusic_poll();
138 }
139 zcmixer_update(zcmixer, emusic_volume, FFCore.usr_music_volume, get_qr(qr_OLD_SCRIPT_VOLUME));
140
141 while(Paused && !Advance && !Quit)
142 {
143 // have to call this, otherwise we'll get an infinite loop
144 syskeys();
145 // to keep fps constant
146 updatescr(allowwavy);
147 throttleFPS();
148
149 #ifdef _WIN32
150
151 if(use_dwm_flush)
152 {
153 do_DwmFlush();
154 }
155
156 #endif
157
158 // to keep music playing
159 if(zcmusic!=NULL)
160 {
161 zcmusic_poll();
162 }
163 zcmixer_update(zcmixer, emusic_volume, FFCore.usr_music_volume, get_qr(qr_OLD_SCRIPT_VOLUME));
164
165 update_hw_screen();
166 }
167
168 //if(Quit)
169 // return;
170 /*
171 if(Playing && game->get_time()<MAXTIME)
172 game->change_time(1);
173 */
174 Advance=false;
175 ++frame;
176
177 syskeys();
178 // Someday... maybe install a Turbo button here?
179 updatescr(allowwavy);
180 throttleFPS();
181
182 #ifdef _WIN32
183
184 if(use_dwm_flush)
185 {
186 do_DwmFlush();
187 }
188
189 #endif
190
191 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
192 if(sfxcleanup)
193 sfx_cleanup();
194 }
195
196 18513311 mapscr* GetMapscr(int32_t mapref)
197 {
198
6/15
✓ Branch 0 taken 30619 times.
✓ Branch 1 taken 17379802 times.
✓ Branch 2 taken 135332 times.
✓ Branch 3 taken 16153 times.
✓ Branch 4 taken 1957 times.
✓ Branch 5 taken 949448 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
18513311 switch(mapref)
199 {
200 30619 case MAPSCR_TEMP0: return FFCore.tempScreens[0]; //Temp layer 0
201 135332 case MAPSCR_TEMP1: return FFCore.tempScreens[1]; //Temp layer 1
202 16153 case MAPSCR_TEMP2: return FFCore.tempScreens[2]; //Temp layer 2
203 1957 case MAPSCR_TEMP3: return FFCore.tempScreens[3]; //Temp layer 3
204 949448 case MAPSCR_TEMP4: return FFCore.tempScreens[4]; //Temp layer 4
205 case MAPSCR_TEMP5: return FFCore.tempScreens[5]; //Temp layer 5
206 case MAPSCR_TEMP6: return FFCore.tempScreens[6]; //Temp layer 6
207 case MAPSCR_SCROLL0: return FFCore.ScrollingScreens[0]; //Temp scrolllayer 0
208 case MAPSCR_SCROLL1: return FFCore.ScrollingScreens[1]; //Temp scrolllayer 1
209 case MAPSCR_SCROLL2: return FFCore.ScrollingScreens[2]; //Temp scrolllayer 2
210 case MAPSCR_SCROLL3: return FFCore.ScrollingScreens[3]; //Temp scrolllayer 3
211 case MAPSCR_SCROLL4: return FFCore.ScrollingScreens[4]; //Temp scrolllayer 4
212 case MAPSCR_SCROLL5: return FFCore.ScrollingScreens[5]; //Temp scrolllayer 5
213 case MAPSCR_SCROLL6: return FFCore.ScrollingScreens[6]; //Temp scrolllayer 6
214 default:
215 {
216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17379802 times.
17379802 if(mapref < 0) return NULL; //Bad negative value
217 17379802 else return &TheMaps[mapref]; //Standard mapdata
218 }
219 }
220 18513311 }
221
222 int32_t getMap(int32_t ref)
223 {
224 switch(ref)
225 {
226 case MAPSCR_TEMP0:
227 return currmap+1;
228 case MAPSCR_TEMP1:
229 return FFCore.tempScreens[0]->layermap[0];
230 case MAPSCR_TEMP2:
231 return FFCore.tempScreens[0]->layermap[1];
232 case MAPSCR_TEMP3:
233 return FFCore.tempScreens[0]->layermap[2];
234 case MAPSCR_TEMP4:
235 return FFCore.tempScreens[0]->layermap[3];
236 case MAPSCR_TEMP5:
237 return FFCore.tempScreens[0]->layermap[4];
238 case MAPSCR_TEMP6:
239 return FFCore.tempScreens[0]->layermap[5];
240 case MAPSCR_SCROLL0:
241 return scrolling_map+1;
242 case MAPSCR_SCROLL1:
243 return FFCore.ScrollingScreens[0]->layermap[0];
244 case MAPSCR_SCROLL2:
245 return FFCore.ScrollingScreens[0]->layermap[1];
246 case MAPSCR_SCROLL3:
247 return FFCore.ScrollingScreens[0]->layermap[2];
248 case MAPSCR_SCROLL4:
249 return FFCore.ScrollingScreens[0]->layermap[3];
250 case MAPSCR_SCROLL5:
251 return FFCore.ScrollingScreens[0]->layermap[4];
252 case MAPSCR_SCROLL6:
253 return FFCore.ScrollingScreens[0]->layermap[5];
254 default:
255 return (ref / MAPSCRS + 1);
256 }
257 }
258 int32_t getScreen(int32_t ref)
259 {
260 switch(ref)
261 {
262 case MAPSCR_TEMP0:
263 return currscr;
264 case MAPSCR_TEMP1:
265 return FFCore.tempScreens[0]->layerscreen[0];
266 case MAPSCR_TEMP2:
267 return FFCore.tempScreens[0]->layerscreen[1];
268 case MAPSCR_TEMP3:
269 return FFCore.tempScreens[0]->layerscreen[2];
270 case MAPSCR_TEMP4:
271 return FFCore.tempScreens[0]->layerscreen[3];
272 case MAPSCR_TEMP5:
273 return FFCore.tempScreens[0]->layerscreen[4];
274 case MAPSCR_TEMP6:
275 return FFCore.tempScreens[0]->layerscreen[5];
276 case MAPSCR_SCROLL0:
277 return scrolling_scr;
278 case MAPSCR_SCROLL1:
279 return FFCore.ScrollingScreens[0]->layerscreen[0];
280 case MAPSCR_SCROLL2:
281 return FFCore.ScrollingScreens[0]->layerscreen[1];
282 case MAPSCR_SCROLL3:
283 return FFCore.ScrollingScreens[0]->layerscreen[2];
284 case MAPSCR_SCROLL4:
285 return FFCore.ScrollingScreens[0]->layerscreen[3];
286 case MAPSCR_SCROLL5:
287 return FFCore.ScrollingScreens[0]->layerscreen[4];
288 case MAPSCR_SCROLL6:
289 return FFCore.ScrollingScreens[0]->layerscreen[5];
290 default:
291 return (ref % MAPSCRS);
292 }
293 }
294
295 #include "zconsole/ConsoleLogger.h"
296
297 //no ifdef here
298 115 CConsoleLoggerEx coloured_console;
299 extern CConsoleLoggerEx zscript_coloured_console;
300
301 int32_t FFScript::UpperToLower(std::string *s)
302 {
303 if ( s->size() < 1 )
304 {
305 Z_scripterrlog("String passed to UpperToLower() is too small. Size is: %d \n", s->size());
306 return 0;
307 }
308 for ( size_t q = 0; q < s->size(); ++q )
309 {
310 //if ( s->at(q) >= 'A' || s->at(q) <= 'Z' )
311 //{
312 // s->at(q) += 32;
313 //}
314 s->at(q) += 32 * (s->at(q) >= 'A' && s->at(q) <= 'Z');
315 }
316 return 1;
317 }
318
319 int32_t FFScript::LowerToUpper(std::string *s)
320 {
321 if ( s->size() < 1 )
322 {
323 Z_scripterrlog("String passed to LowerToUpper() is too small. Size is: %d \n", s->size());
324 return 0;
325 }
326 for ( size_t q = 0; q < s->size(); ++q )
327 {
328 //if ( s->at(q) >= 'a' || s->at(q) <= 'z' )
329 //{
330 // s->at(q) -= 32;
331 //}
332 s->at(q) -= 32 * (s->at(q) >= 'a' && s->at(q) <= 'z');
333 }
334 return 1;
335 }
336
337 int32_t FFScript::ConvertCase(std::string *s)
338 {
339 if ( s->size() < 1 )
340 {
341 Z_scripterrlog("String passed to UpperToLower() is too small. Size is: %d \n", s->size());
342 return 0;
343 }
344 for ( size_t q = 0; q < s->size(); ++q )
345 {
346 if ( s->at(q) >= 'a' || s->at(q) <= 'z' )
347 {
348 s->at(q) -= 32;
349 }
350 else if ( s->at(q) >= 'A' || s->at(q) <= 'Z' )
351 {
352 s->at(q) += 32;
353 }
354 }
355 zprint("FFScript::ConvertCase(std::string s), post-conversion, string is: %s\n", s->c_str());
356 return 1;
357 }
358
359 bool FFScript::isNumber(char chr)
360 {
361 if ( chr >= '0' )
362 {
363 if ( chr <= '9' ) return true;
364 }
365 return false;
366 }
367
368 int32_t FFScript::ilen(char *p)
369 {
370 int32_t ret = 0; int32_t pos = 0;
371 if(p[pos] == '-')
372 ret++;
373 for(; FFCore.isNumber(p[pos + ret]); ++ret);
374 return ret;
375 }
376
377 int32_t FFScript::zc_strlen(char *p)
378 {
379 int32_t count = 0;
380
381 while(*p!='\0')
382 {
383 count++;
384 p++;
385 }
386
387 return count;
388 }
389
390 int32_t FFScript::atox(char *ip_str)
391 {
392 char tmp[2]={'2','\0'};
393 int32_t op_val=0, i=0, ip_len = FFCore.zc_strlen(ip_str);
394
395 if(strncmp(ip_str, "0x", 2) == 0)
396 {
397 ip_str +=2;
398 ip_len -=2;
399 }
400
401 for(i=0;i<ip_len;i++)
402 {
403 op_val *= 0x10;
404 switch(ip_str[i])
405 {
406 case 'a':
407 op_val += 0xa;
408 break;
409 case 'b':
410 op_val += 0xb;
411 break;
412 case 'c':
413 op_val += 0xc;
414 break;
415 case 'd':
416 op_val += 0xd;
417 break;
418 case 'e':
419 op_val += 0xe;
420 break;
421 case 'f':
422 op_val += 0xf;
423 break;
424 case '0':
425 case '1':
426 case '2':
427 case '3':
428 case '4':
429 case '5':
430 case '6':
431 case '7':
432 case '8':
433 case '9':
434 tmp[0] = ip_str[i];
435 op_val += atoi(tmp);
436 break;
437 default :
438 op_val += 0x0;
439 break;
440 }
441 }
442 return op_val;
443 }
444
445 char runningItemScripts[256] = {0};
446
447 //item *FFCore.temp_ff_item = NULL;
448 //enemy *FFCore.temp_ff_enemy = NULL;
449 //weapon *FFCore.temp_ff_lweapon = NULL;
450 //weapon *FFCore.temp_ff_eweapon = NULL;
451
452 #include "zc/zelda.h"
453 #include "particles.h"
454 #include "zc/hero.h"
455 extern int32_t directItem; //Is set if Player is currently using an item directly
456 extern int32_t directItemA;
457 extern int32_t directItemB;
458 extern int32_t directItemX;
459 extern int32_t directItemY;
460
461 #include "zc/guys.h"
462 #include "gamedata.h"
463 #include "zc/zc_init.h"
464 #include "base/zsys.h"
465 #include "base/misctypes.h"
466 #include "zc/title.h"
467 #include "zscriptversion.h"
468
469 #include "pal.h"
470 #include "base/zdefs.h"
471 #include "zc/rendertarget.h"
472
473 #include "zc/zc_custom.h"
474 #include "qst.h"
475
476 #define zc_max(a,b) ((a)>(b)?(a):(b))
477 /*template <typename T>
478 T zc_max(T a, T b)
479 {
480 return (a > b) ? a : b;
481 }*/
482
483 #define zc_min(a,b) ((a)<(b)?(a):(b))
484
485 #ifdef _MSC_VER
486 #pragma warning ( disable : 4800 ) //int32_t to bool town. population: lots.
487 #endif
488
489 #define NUMSHOPS 256
490 #define NUMINFOSHOPS 511
491
492 //! New datatype vars for 2.54:
493
494 //spritedata sp->member
495
496
497 using std::string;
498
499 extern particle_list particles;
500 extern HeroClass Hero;
501 extern char *guy_string[];
502 extern int32_t skipcont;
503
504 PALETTE tempgreypal; //Palettes go here. This is used for Greyscale() / Monochrome()
505 PALETTE userPALETTE[256]; //Palettes go here. This is used for Greyscale() / Monochrome()
506 PALETTE tempblackpal; //Used for storing the palette while fading to black
507
508 115 FFScript ffengine;
509
510 byte FF_hero_action; //This way, we can make safe replicas of internal Hero actions to be set by script.
511
512 int32_t FF_screenbounds[4]; //edges of the screen, left, right, top, bottom used for where to scroll.
513 int32_t FF_screen_dimensions[4]; //height, width, displaywidth, displayheight
514 int32_t FF_subscreen_dimensions[4];
515 int32_t FF_eweapon_removal_bounds[4]; //left, right, top, bottom coordinates for automatic eweapon removal.
516 int32_t FF_lweapon_removal_bounds[4]; //left, right, top, bottom coordinates for automatic lweapon removal.
517 int32_t FF_clocks[FFSCRIPTCLASS_CLOCKS]; //Will be used for Heroaction, anims, and so forth
518 byte ScriptDrawingRules[SCRIPT_DRAWING_RULES];
519 int32_t FF_UserMidis[NUM_USER_MIDI_OVERRIDES]; //MIDIs to use for Game Over, and similar to override system defaults.
520
521 int32_t get_int_arr(const int32_t ptr, int32_t indx);
522 void set_int_arr(const int32_t ptr, int32_t indx, int32_t val);
523 int32_t sz_int_arr(const int32_t ptr);
524
525 //We gain some speed by not passing as arguments
526 int32_t sarg1 = 0;
527 int32_t sarg2 = 0;
528 std::vector<int32_t> *sargvec;
529 std::string *sargstr;
530 refInfo *ri = NULL;
531 script_data *curscript = NULL;
532 int32_t(*stack)[MAX_SCRIPT_REGISTERS] = NULL;
533 std::vector<int32_t> zs_vargs;
534 ScriptType curScriptType;
535 word curScriptNum;
536 int32_t curScriptIndex;
537 bool script_funcrun = false;
538 std::string* destructstr = nullptr;
539
540 static std::vector<ScriptType> curScriptType_cache;
541 static std::vector<int32_t> curScriptNum_cache;
542 static std::vector<int32_t> curScriptIndex_cache;
543 static std::vector<int32_t> sarg1cache;
544 static std::vector<int32_t> sarg2cache;
545 static std::vector<std::vector<int32_t>*> sargvec_cache;
546 static std::vector<std::string*> sargstr_cache;
547 static std::vector<refInfo*> ricache;
548 static std::vector<script_data*> sdcache;
549 static std::vector<int32_t(*)[MAX_SCRIPT_REGISTERS]> stackcache;
550 10 void push_ri()
551 {
552 10 sarg1cache.push_back(sarg1);
553 10 sarg2cache.push_back(sarg2);
554 10 curScriptType_cache.push_back(curScriptType);
555 10 curScriptNum_cache.push_back(curScriptNum);
556 10 curScriptIndex_cache.push_back(curScriptIndex);
557 10 sargvec_cache.push_back(sargvec);
558 10 sargstr_cache.push_back(sargstr);
559 10 ricache.push_back(ri);
560 10 sdcache.push_back(curscript);
561 10 stackcache.push_back(stack);
562 10 }
563 10 void pop_ri()
564 {
565 10 sarg1 = sarg1cache.back(); sarg1cache.pop_back();
566 10 sarg2 = sarg2cache.back(); sarg2cache.pop_back();
567 10 curScriptType = curScriptType_cache.back(); curScriptType_cache.pop_back();
568 10 curScriptNum = curScriptNum_cache.back(); curScriptNum_cache.pop_back();
569 10 curScriptIndex = curScriptIndex_cache.back(); curScriptIndex_cache.pop_back();
570 10 sargvec = sargvec_cache.back(); sargvec_cache.pop_back();
571 10 sargstr = sargstr_cache.back(); sargstr_cache.pop_back();
572 10 ri = ricache.back(); ricache.pop_back();
573 10 curscript = sdcache.back(); sdcache.pop_back();
574 10 stack = stackcache.back(); stackcache.pop_back();
575 10 }
576
577 static int32_t numInstructions = 0; // Used to detect hangs
578 static bool scriptCanSave = true;
579
580 std::vector<refInfo*> genericActiveData;
581 std::vector<int32_t(*)[MAX_SCRIPT_REGISTERS]> generic_active_stack;
582 bool gen_active_doscript = false, gen_active_initialized = false;
583
584 283699 struct ScriptEngineData {
585 refInfo ref;
586 int32_t stack[MAX_SCRIPT_REGISTERS];
587 // This is used as a boolean for all but ScriptType::Item.
588 283699 byte doscript = true;
589 bool waitdraw;
590 bool initialized;
591
592 2573803 void reset()
593 {
594 // No need to zero the stack.
595 2573803 ref = refInfo();
596 2573803 doscript = true;
597 2573803 waitdraw = false;
598 2573803 initialized = false;
599 2573803 }
600 };
601
602 // (type, index) => ScriptEngineData
603 115 static std::map<std::pair<ScriptType, word>, ScriptEngineData> scriptEngineDatas;
604
605 349501436 static ScriptEngineData& get_script_engine_data(ScriptType type, int index)
606 {
607
7/8
✓ Branch 0 taken 333214818 times.
✓ Branch 1 taken 16286618 times.
✓ Branch 2 taken 333214818 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 316944739 times.
✓ Branch 5 taken 16270079 times.
✓ Branch 6 taken 17616 times.
✓ Branch 7 taken 316927123 times.
349501436 if (type == ScriptType::DMap || type == ScriptType::OnMap || type == ScriptType::PassiveSubscreen || type == ScriptType::ActiveSubscreen)
608 {
609 // `index` is used for dmapref, not for different script engine data.
610 32574313 index = 0;
611 32574313 }
612
613 349501436 return scriptEngineDatas[{type, index}];
614 }
615
616 40 static ScriptEngineData& get_script_engine_data(ScriptType type)
617 {
618 40 return scriptEngineDatas[{type, 0}];
619 }
620
621 407 void FFScript::clear_script_engine_data()
622 {
623 407 scriptEngineDatas.clear();
624 407 }
625
626 2111979 void FFScript::reset_script_engine_data(ScriptType type, int index)
627 {
628 2111979 get_script_engine_data(type, index).reset();
629 2111979 }
630
631 163737 void FFScript::clear_script_engine_data(ScriptType type, int index)
632 {
633
4/8
✓ Branch 0 taken 163737 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163737 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 163737 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 163737 times.
163737 if (type == ScriptType::DMap || type == ScriptType::OnMap || type == ScriptType::PassiveSubscreen || type == ScriptType::ActiveSubscreen)
634 {
635 // `index` is used for dmapref, not for different script engine data.
636 index = 0;
637 }
638
639 163737 auto it = scriptEngineDatas.find({type, index});
640
2/2
✓ Branch 0 taken 163685 times.
✓ Branch 1 taken 52 times.
163737 if (it != scriptEngineDatas.end())
641 {
642 52 scriptEngineDatas.erase(it);
643 52 }
644 163737 }
645
646 58860 void FFScript::clear_script_engine_data_of_type(ScriptType type)
647 {
648 38008406 std::erase_if(scriptEngineDatas, [&](auto& kv) { return kv.first.first == type; });
649 58860 }
650
651 194 refInfo& FFScript::ref(ScriptType type, int index)
652 {
653 194 return get_script_engine_data(type, index).ref;
654 }
655
656 32450280 byte& FFScript::doscript(ScriptType type, int index)
657 {
658 32450280 return get_script_engine_data(type, index).doscript;
659 }
660
661 267121553 bool& FFScript::waitdraw(ScriptType type, int index)
662 {
663 267121553 return get_script_engine_data(type, index).waitdraw;
664 }
665
666 // Returns true if registers had to be initialized.
667 8914035 static bool set_current_script_engine_data(ScriptType type, int script, int index)
668 {
669 8914035 bool got_initialized = false;
670
671 8914035 auto& data = get_script_engine_data(type, index);
672 8914035 ri = &data.ref;
673 8914035 stack = &data.stack;
674
675
8/11
✓ Branch 0 taken 270763 times.
✓ Branch 1 taken 9910 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4680330 times.
✓ Branch 4 taken 4287 times.
✓ Branch 5 taken 3885370 times.
✓ Branch 6 taken 13182 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 12104 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 38089 times.
8914035 switch (type)
676 {
677 case ScriptType::FFC:
678 {
679 4680330 curscript = ffscripts[script];
680
681
2/2
✓ Branch 0 taken 4664675 times.
✓ Branch 1 taken 15655 times.
4680330 if (!data.initialized)
682 {
683 15655 got_initialized = true;
684 15655 memcpy(ri->d, tmpscr->ffcs[index].initd, 8 * sizeof(int32_t));
685 15655 memcpy(ri->a, tmpscr->ffcs[index].inita, 2 * sizeof(int32_t));
686 15655 data.initialized = true;
687 15655 }
688
689 4680330 ri->ffcref = index;
690 }
691 4680330 break;
692
693 // case ScriptType::NPC:
694 // {
695 // int32_t npc_index = GuyH::getNPCIndex(i);
696 // enemy *w = (enemy*)guys.spr(npc_index);
697 // ri = &(w->scrmem->scriptData);
698 // curscript = guyscripts[w->script];
699 // stack = &(w->scrmem->stack);
700 // ri->guyref = i;
701
702 // if (!w->initialised)
703 // {
704 // got_initialized = true;
705 // for ( int32_t q = 0; q < 8; q++ )
706 // {
707 // ri->d[q] = w->initD[q];
708 // }
709 // w->initialised = 1;
710 // }
711 // }
712 // break;
713
714 // case ScriptType::Lwpn:
715 // {
716 // int32_t lwpn_index = LwpnH::getLWeaponIndex(i);
717 // weapon *w = (weapon*)Lwpns.spr(lwpn_index);
718 // ri = &(w->scrmem->scriptData);
719 // curscript = lwpnscripts[w->weaponscript];
720 // stack = &(w->scrmem->stack);
721 // ri->lwpn = i;
722
723 // if (!w->initialised)
724 // {
725 // got_initialized = true;
726 // for ( int32_t q = 0; q < 8; q++ )
727 // {
728 // ri->d[q] = w->weap_initd[q]; //w->initiald[q];
729 // }
730 // w->initialised = 1;
731 // }
732 // }
733 // break;
734
735 // case ScriptType::Ewpn:
736 // {
737 // int32_t ewpn_index = EwpnH::getEWeaponIndex(i);
738 // weapon *w = (weapon*)Ewpns.spr(ewpn_index);
739 // ri = &(w->scrmem->scriptData);
740 // curscript = ewpnscripts[w->weaponscript];
741 // stack = &(w->scrmem->stack);
742 // ri->ewpn = i;
743
744 // if (!w->initialised)
745 // {
746 // got_initialized = true;
747 // for ( int32_t q = 0; q < 8; q++ )
748 // {
749 // ri->d[q] = w->weap_initd[q];
750 // }
751 // w->initialised = 1;
752 // }
753 // }
754 // break;
755
756 // case ScriptType::ItemSprite:
757 // {
758 // int32_t the_index = ItemH::getItemIndex(i);
759 // item *w = (item*)items.spr(the_index);
760 // ri = &(w->scrmem->scriptData);
761 // curscript = itemspritescripts[w->script];
762 // stack = &(w->scrmem->stack);
763 // ri->itemref = i;
764
765 // if (!w->initialised)
766 // {
767 // got_initialized = true;
768 // for ( int32_t q = 0; q < 8; q++ )
769 // {
770 // ri->d[q] = w->initD[q];
771 // }
772 // w->initialised = 1;
773 // }
774 // }
775 // break;
776
777 case ScriptType::Item:
778 {
779 4287 int32_t i = index;
780 4287 int32_t new_i = 0;
781
2/2
✓ Branch 0 taken 4093 times.
✓ Branch 1 taken 194 times.
4287 bool collect = ( ( i < 1 ) || (i == COLLECT_SCRIPT_ITEM_ZERO) );
782
3/4
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 4093 times.
✓ Branch 2 taken 194 times.
✗ Branch 3 not taken.
4287 new_i = ( collect ) ? (( i != COLLECT_SCRIPT_ITEM_ZERO ) ? (i * -1) : 0) : i;
783
784 4287 curscript = itemscripts[script];
785
786
2/2
✓ Branch 0 taken 3278 times.
✓ Branch 1 taken 1009 times.
4287 if (!data.initialized)
787 {
788 1009 got_initialized = true;
789
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 815 times.
1009 memcpy(ri->d, ( collect ) ? itemsbuf[new_i].initiald : itemsbuf[i].initiald, 8 * sizeof(int32_t));
790
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 815 times.
1009 memcpy(ri->a, ( collect ) ? itemsbuf[new_i].initiala : itemsbuf[i].initiala, 2 * sizeof(int32_t));
791 1009 data.initialized = true;
792 1009 }
793
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 4093 times.
4287 ri->idata = ( collect ) ? new_i : i; //'this' pointer
794 }
795 4287 break;
796
797 case ScriptType::Global:
798 {
799 3885370 curscript = globalscripts[script];
800 }
801 3885370 break;
802
803 // case ScriptType::Generic:
804 // {
805 // user_genscript& scr = user_scripts[script];
806 // stack = &scr.stack;
807 // ri = &scr.ri;
808 // ri->genericdataref = script;
809 // curscript = genericscripts[script];
810 // scr.waitevent = false;
811 // if(!scr.initialized)
812 // {
813 // got_initialized = true;
814 // scr.initialized = true;
815 // memcpy(ri->d, scr.initd, 8 * sizeof(int32_t));
816 // }
817 // }
818 // break;
819
820 // case ScriptType::GenericFrozen:
821 // {
822 // ri = genericActiveData.back();
823 // ri->genericdataref = script;
824 // curscript = genericscripts[script];
825 // stack = generic_active_stack.back();
826 // if(!gen_active_initialized)
827 // {
828 // got_initialized = true;
829 // gen_active_initialized = true;
830 // memcpy(ri->d, user_scripts[script].initd, 8 * sizeof(int32_t));
831 // }
832 // }
833 // break;
834
835 case ScriptType::Player:
836 {
837 270763 curscript = playerscripts[script];
838 }
839 270763 break;
840
841 case ScriptType::DMap:
842 {
843 13182 curscript = dmapscripts[script];
844 13182 ri->dmapsref = index;
845 //how do we clear initialised on dmap change?
846
2/2
✓ Branch 0 taken 13169 times.
✓ Branch 1 taken 13 times.
13182 if ( !data.initialized )
847 {
848 13 got_initialized = true;
849
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 13 times.
117 for ( int32_t q = 0; q < 8; q++ )
850 {
851 104 ri->d[q] = DMaps[ri->dmapsref].initD[q];// * 10000;
852 104 }
853 13 data.initialized = true;
854 13 }
855 }
856 13182 break;
857
858 case ScriptType::OnMap:
859 {
860 curscript = dmapscripts[script];
861 ri->dmapsref = index;
862 if (!data.initialized)
863 {
864 got_initialized = true;
865 for ( int32_t q = 0; q < 8; q++ )
866 {
867 ri->d[q] = DMaps[ri->dmapsref].onmap_initD[q];
868 }
869 data.initialized = true;
870 }
871 }
872 break;
873
874 case ScriptType::ActiveSubscreen:
875 {
876 12104 curscript = dmapscripts[script];
877 12104 ri->dmapsref = index;
878
2/2
✓ Branch 0 taken 12064 times.
✓ Branch 1 taken 40 times.
12104 if (!data.initialized)
879 {
880 40 got_initialized = true;
881
2/2
✓ Branch 0 taken 320 times.
✓ Branch 1 taken 40 times.
360 for ( int32_t q = 0; q < 8; q++ )
882 {
883 320 ri->d[q] = DMaps[ri->dmapsref].sub_initD[q];
884 320 }
885 40 data.initialized = true;
886 40 }
887 }
888 12104 break;
889
890 case ScriptType::PassiveSubscreen:
891 {
892 curscript = dmapscripts[script];
893 ri->dmapsref = index;
894 if (!data.initialized)
895 {
896 got_initialized = true;
897 for ( int32_t q = 0; q < 8; q++ )
898 {
899 ri->d[q] = DMaps[ri->dmapsref].sub_initD[q];
900 }
901 data.initialized = true;
902 }
903 }
904 break;
905
906 case ScriptType::Screen:
907 {
908 9910 curscript = screenscripts[script];
909
910
2/2
✓ Branch 0 taken 9887 times.
✓ Branch 1 taken 23 times.
9910 if (!data.initialized)
911 {
912 23 got_initialized = true;
913
2/2
✓ Branch 0 taken 184 times.
✓ Branch 1 taken 23 times.
207 for ( int32_t q = 0; q < 8; q++ )
914 {
915 184 ri->d[q] = tmpscr->screeninitd[q];// * 10000;
916 184 }
917 23 data.initialized = true;
918 23 }
919 }
920 9910 break;
921
922 case ScriptType::Combo:
923 {
924 38089 curscript = comboscripts[script];
925
926 38089 int32_t pos = combopos_ref_to_pos(index);
927 38089 int32_t lyr = combopos_ref_to_layer(index);
928 38089 int32_t id = FFCore.tempScreens[lyr]->data[pos];
929
2/2
✓ Branch 0 taken 37715 times.
✓ Branch 1 taken 374 times.
38089 if (!data.initialized)
930 {
931 374 got_initialized = true;
932 374 memset(ri->d, 0, 8 * sizeof(int32_t));
933
2/2
✓ Branch 0 taken 748 times.
✓ Branch 1 taken 374 times.
1122 for ( int32_t q = 0; q < 2; q++ )
934 748 ri->d[q] = combobuf[id].initd[q];
935 374 data.initialized = true;
936 374 }
937
938 38089 ri->combosref = id; //'this' pointer
939 38089 ri->comboposref = index; //used for X(), Y(), Layer(), and so forth.
940 38089 break;
941 }
942 }
943
944 8914035 return got_initialized;
945 }
946
947 //Sprite script data
948 refInfo npcScriptData[256];
949 refInfo lweaponScriptData[256]; //should this be lweapon and eweapon, separate stacks?
950 refInfo eweaponScriptData[256]; //should this be lweapon and eweapon, separate stacks?
951 refInfo itemactiveScriptData[256];
952
953 int32_t ffmisc[MAXFFCS][16];
954
955
3/4
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58765 times.
✓ Branch 3 taken 115 times.
58880 user_genscript user_scripts[NUMSCRIPTSGENERIC];
956 int32_t genscript_timing = SCR_TIMING_START_FRAME;
957 static word max_valid_genscript;
958 static dword max_valid_object;
959
960 363 void user_genscript::quit()
961 {
962 363 doscript = false;
963
1/2
✓ Branch 0 taken 363 times.
✗ Branch 1 not taken.
363 if(indx > -1)
964 {
965 363 FFCore.deallocateAllArrays(ScriptType::Generic, indx);
966 363 }
967 363 }
968
969 527 void countGenScripts()
970 {
971 527 max_valid_genscript = 0;
972
2/2
✓ Branch 0 taken 269297 times.
✓ Branch 1 taken 527 times.
269824 for(auto q = 1; q < NUMSCRIPTSGENERIC; ++q)
973 {
974
4/4
✓ Branch 0 taken 210532 times.
✓ Branch 1 taken 58765 times.
✓ Branch 2 taken 210378 times.
✓ Branch 3 taken 154 times.
269297 if(genericscripts[q] && genericscripts[q]->valid())
975 154 max_valid_genscript = q;
976 269297 }
977 527 }
978 407 void countObjects()
979 {
980 407 max_valid_object = 0;
981
2/2
✓ Branch 0 taken 87402436 times.
✓ Branch 1 taken 407 times.
87402843 for(auto q = 0; q < MAX_USER_OBJECTS; ++q)
982 {
983
1/2
✓ Branch 0 taken 87402436 times.
✗ Branch 1 not taken.
87402436 if(script_objects[q].reserved)
984 max_valid_object = q+1;
985 87402436 }
986 407 }
987 19586 void timeExitAllGenscript(byte exState)
988 {
989
2/2
✓ Branch 0 taken 10028032 times.
✓ Branch 1 taken 19586 times.
10047618 for(user_genscript& g : user_scripts)
990 10028032 g.timeExit(exState);
991 19586 }
992 303801 void throwGenScriptEvent(int32_t event)
993 {
994
2/2
✓ Branch 0 taken 38892 times.
✓ Branch 1 taken 303801 times.
342693 for(auto q = 1; q <= max_valid_genscript; ++q)
995 {
996 38892 user_genscript& scr = user_scripts[q];
997
2/2
✓ Branch 0 taken 12956 times.
✓ Branch 1 taken 25936 times.
38892 if(!scr.doscript) continue;
998
2/2
✓ Branch 0 taken 9718 times.
✓ Branch 1 taken 3238 times.
12956 if(!genericscripts[q]->valid()) continue;
999
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9718 times.
9718 if(!scr.waitevent) continue;
1000 if(scr.eventstate & (1<<event))
1001 {
1002 scr.ri.d[rEXP1] = event*10000;
1003 scr.waitevent = false;
1004
1005 //Run the script!
1006 ZScriptVersion::RunScript(ScriptType::Generic, q, q);
1007 }
1008 }
1009 303801 }
1010
1011 74 void load_genscript(const gamedata& gd)
1012 {
1013
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 74 times.
37962 for(size_t q = 0; q < NUMSCRIPTSGENERIC; ++q)
1014 {
1015 37888 user_genscript& gen = user_scripts[q];
1016 37888 gen.clear();
1017 37888 gen.indx = q;
1018 37888 gen.doscript = gd.gen_doscript[q];
1019 37888 gen.exitState = gd.gen_exitState[q];
1020 37888 gen.reloadState = gd.gen_reloadState[q];
1021 37888 gen.eventstate = gd.gen_eventstate[q];
1022 37888 memcpy(gen.initd, gd.gen_initd[q], sizeof(gen.initd));
1023 37888 gen.data = gd.gen_data[q];
1024 37888 gen.dataResize(gd.gen_dataSize[q]);
1025 37888 }
1026 74 }
1027 46 void load_genscript(const zinitdata& zd)
1028 {
1029
2/2
✓ Branch 0 taken 23552 times.
✓ Branch 1 taken 46 times.
23598 for(size_t q = 0; q < NUMSCRIPTSGENERIC; ++q)
1030 {
1031 23552 user_genscript& gen = user_scripts[q];
1032 23552 gen.clear();
1033 23552 gen.indx = q;
1034 23552 gen.doscript = zd.gen_doscript[q];
1035 23552 gen.exitState = zd.gen_exitState[q];
1036 23552 gen.reloadState = zd.gen_reloadState[q];
1037 23552 gen.eventstate = zd.gen_eventstate[q];
1038 23552 memcpy(gen.initd, zd.gen_initd[q], sizeof(gen.initd));
1039 23552 gen.dataResize(zd.gen_data[q].size());
1040 23552 gen.data = zd.gen_data[q];
1041 23552 gen.dataResize(zd.gen_dataSize[q]);
1042 23552 }
1043 46 }
1044
1045 void save_genscript(gamedata& gd)
1046 {
1047 for(size_t q = 0; q < NUMSCRIPTSGENERIC; ++q)
1048 {
1049 user_genscript const& gen = user_scripts[q];
1050 gd.gen_doscript[q] = gen.doscript;
1051 gd.gen_exitState[q] = gen.exitState;
1052 gd.gen_reloadState[q] = gen.reloadState;
1053 gd.gen_eventstate[q] = gen.eventstate;
1054 memcpy(gd.gen_initd[q], gen.initd, sizeof(gen.initd));
1055 gd.gen_dataSize[q] = gen.dataSize();
1056 gd.gen_data[q] = gen.data;
1057 }
1058 }
1059
1060 300391009 void FFScript::runGenericPassiveEngine(int32_t scrtm)
1061 {
1062
2/2
✓ Branch 0 taken 3460760 times.
✓ Branch 1 taken 296930249 times.
300391009 if(!max_valid_genscript) return; //No generic scripts in the quest!
1063 //zprint2("Processing timing %d\n", scrtm);
1064 3460760 bool init = (scrtm == SCR_TIMING_INIT);
1065
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3460759 times.
3460760 if(!init)
1066 {
1067
2/2
✓ Branch 0 taken 22119 times.
✓ Branch 1 taken 3438640 times.
3460759 if(genscript_timing != scrtm)
1068 {
1069 //zprint2("Generic script timing jump: expected '%d', found '%d'\n", genscript_timing, scrtm);
1070
2/2
✓ Branch 0 taken 77115 times.
✓ Branch 1 taken 22119 times.
99234 while(genscript_timing != scrtm)
1071 77115 runGenericPassiveEngine(genscript_timing);
1072 22119 }
1073 3460759 }
1074
2/2
✓ Branch 0 taken 41529120 times.
✓ Branch 1 taken 3460760 times.
44989880 for(auto q = 1; q <= max_valid_genscript; ++q)
1075 {
1076 41529120 user_genscript& scr = user_scripts[q];
1077
2/2
✓ Branch 0 taken 13843030 times.
✓ Branch 1 taken 27686090 times.
41529120 if(!scr.doscript) continue;
1078
2/2
✓ Branch 0 taken 10382275 times.
✓ Branch 1 taken 3460755 times.
13843030 if(!genericscripts[q]->valid()) continue;
1079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10382275 times.
10382275 if(scr.waitevent) continue;
1080
8/8
✓ Branch 0 taken 10382273 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 10204736 times.
✓ Branch 3 taken 177537 times.
✓ Branch 4 taken 10204389 times.
✓ Branch 5 taken 347 times.
✓ Branch 6 taken 9760653 times.
✓ Branch 7 taken 443736 times.
10382275 if(!init && (scr.waituntil > scrtm || (!scr.wait_atleast && scr.waituntil != scrtm)))
1081 9938190 continue;
1082
1083 //Run the script!
1084 444085 ZScriptVersion::RunScript(ScriptType::Generic, q, q);
1085 444085 }
1086
4/4
✓ Branch 0 taken 3460759 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 3372038 times.
✓ Branch 3 taken 88721 times.
3460760 if(init || genscript_timing >= SCR_TIMING_END_FRAME)
1087 88722 genscript_timing = SCR_TIMING_START_FRAME;
1088 3372038 else ++genscript_timing;
1089 300391009 }
1090
1091 5236 void FFScript::initZScriptDMapScripts()
1092 {
1093 5236 scriptEngineDatas[{ScriptType::DMap, 0}] = ScriptEngineData();
1094 5236 scriptEngineDatas[{ScriptType::PassiveSubscreen, 0}] = ScriptEngineData();
1095 5236 }
1096
1097 5260 void FFScript::initZScriptActiveSubscreenScript()
1098 {
1099 5260 scriptEngineDatas[{ScriptType::ActiveSubscreen, 0}] = ScriptEngineData();
1100 5260 }
1101
1102 void FFScript::initZScriptOnMapScript()
1103 {
1104 scriptEngineDatas[{ScriptType::OnMap, 0}] = ScriptEngineData();
1105 }
1106
1107 962 void FFScript::initZScriptHeroScripts()
1108 {
1109 962 scriptEngineDatas[{ScriptType::Player, 0}] = ScriptEngineData();
1110 962 }
1111
1112 902 void FFScript::initZScriptItemScripts()
1113 {
1114
2/2
✓ Branch 0 taken 230912 times.
✓ Branch 1 taken 902 times.
231814 for ( int32_t q = 0; q < 256; q++ )
1115 {
1116 230912 auto& data = get_script_engine_data(ScriptType::Item, q);
1117 230912 data.reset();
1118
1/2
✓ Branch 0 taken 230912 times.
✗ Branch 1 not taken.
230912 data.doscript = (itemsbuf[q].flags&ITEM_PASSIVESCRIPT) && game->item[q];
1119 230912 }
1120
1121
2/2
✓ Branch 0 taken 230912 times.
✓ Branch 1 taken 902 times.
231814 for ( int32_t q = -256; q < 0; q++ )
1122 {
1123 230912 auto& data = get_script_engine_data(ScriptType::Item, q);
1124 230912 data.reset();
1125 230912 data.doscript = 0;
1126 230912 }
1127 902 }
1128
1129 2574844 static int get_mouse_state(int index)
1130 {
1131 2574844 int value = 0;
1132
1/2
✓ Branch 0 taken 2574844 times.
✗ Branch 1 not taken.
2574844 if (replay_is_replaying())
1133 {
1134 2574844 value = replay_get_mouse(index);
1135 2574844 }
1136 else if (index == 0)
1137 {
1138 value = script_mouse_x;
1139 }
1140 else if (index == 1)
1141 {
1142 value = script_mouse_y;
1143 }
1144 else if (index == 2)
1145 {
1146 value = script_mouse_z;
1147 }
1148 else if (index == 3)
1149 {
1150 value = script_mouse_b;
1151 }
1152
1153
1/2
✓ Branch 0 taken 2574844 times.
✗ Branch 1 not taken.
2574844 if (replay_is_recording())
1154 {
1155 replay_set_mouse(index, value);
1156 }
1157
1158 2574844 return value;
1159 }
1160
1161 ///----------------------------------------------//
1162 // New Mapscreen Flags Tools //
1163 ///----------------------------------------------//
1164
1165 /*
1166 void FFScript::set_mapscreenflag_state(mapscr *m, int32_t flagid, bool state)
1167 {
1168 switch(flagid)
1169 {
1170 // Room Types
1171 case MSF_INTERIOR:
1172 if ( state )
1173 m->flags6 |= 1;
1174 else m->flags6 &= ~1;
1175 break;
1176 case MSF_DUNGEON:
1177 if ( state )
1178 m->flags6 |= 2;
1179 else m->flags6 &= ~2;
1180 break;
1181 case MSF_SIDEVIEW:
1182 if ( state )
1183 m->flags7 |= 8;
1184 else m->flags7 &= ~8;
1185 break;
1186
1187 // View
1188 case MSF_INVISHERO:
1189 if ( state )
1190 m->flags3 |= 8;
1191 else m->flags3 &= ~8;
1192 break;
1193 case MSF_NOHEROMARKER:
1194 if ( state )
1195 m->flags7 |= 16;
1196 else m->flags7 &= ~16;
1197 break;
1198
1199 case MSF_NOSUBSCREEN:
1200 if ( state )
1201 m->flags3 |= 16;
1202 else m->flags3 &= ~16;
1203 break;
1204 case MSF_NOOFFSET:
1205 if ( state )
1206 m->flags3 |= 64;
1207 else m->flags3 &= ~64;
1208 break;
1209
1210 case MSF_LAYER2BG:
1211 if ( state )
1212 m->flags7 |= 2;
1213 else m->flags7 &= ~2;
1214 break;
1215 case MSF_LAYER3BG:
1216 if ( state )
1217 m->flags7 |= 1;
1218 else m->flags7 &= ~1;
1219 break;
1220 case MSF_DARKROOM:
1221 if ( state )
1222 m->flags |= 4;
1223 else m->flags &= ~4;
1224 break;
1225
1226 // Secrets
1227 case MSF_BLOCKSHUT:
1228 if ( state )
1229 m->flags |= 1;
1230 else m->flags &= ~1;
1231 break;
1232 case MSF_TEMPSECRETS:
1233 if ( state )
1234 m->flags5 |= 16;
1235 else m->flags5 &= ~16;
1236 break;
1237
1238 case MSF_TRIGPERM:
1239 if ( state )
1240 m->flags6 |= 4;
1241 else m->flags6 &= ~4;
1242 break;
1243 case MSF_ALLTRIGFLAGS:
1244 if ( state )
1245 m->flags6 |= 32;
1246 else m->flags6 &= ~32;
1247 break;
1248 // Warp
1249 case MSF_AUTODIRECT:
1250 if ( state )
1251 m->flags5 |= 4;
1252 else m->flags5 &= ~4;
1253 break;
1254 case MSF_SENDSIRECT:
1255 if ( state )
1256 m->flags5 |= 8;
1257 else m->flags5 &= ~8;
1258 break;
1259 case MSF_MAZEPATHS:
1260 if ( state )
1261 m->flags |= 64;
1262 else m->flags &= ~64;
1263 break;
1264
1265 case MSF_MAZEOVERRIDE:
1266 if ( state )
1267 m->flags8 |= 64;
1268 else m->flags8 &= ~64;
1269 break;
1270 case MSF_SPRITECARRY:
1271 if ( state )
1272 m->flags3 |= 32;
1273 else m->flags3 &= ~32;
1274 break;
1275
1276 case MSF_DIRECTTIMEDWARPS:
1277 if ( state )
1278 m->flags4 |= 4;
1279 else m->flags4 &= ~4;
1280 break;
1281
1282 case MSF_SECRETSISABLETIMEWRP:
1283 if ( state )
1284 m->flags4 |= 8;
1285 else m->flags4 &= ~8;
1286 break;
1287 case MSF_RANDOMTIMEDWARP:
1288 if ( state )
1289 m->flags5 |= 1;
1290 else m->flags5 &= ~1;
1291 break;
1292
1293 // Item
1294 case MSF_HOLDUP:
1295 if ( state )
1296 m->flags3 |= 1;
1297 else m->flags3 &= ~1;
1298 break;
1299
1300 case MSF_FALLS:
1301 if ( state )
1302 m->flags7 |= 4;
1303 else m->flags7 &= ~4;
1304 break;
1305
1306
1307 // Combo
1308 case MSF_MIDAIR:
1309 { //FIX ME!
1310 //! What the ever love of fuck mate?!
1311 // byte *f2 = &(m->flags2);
1312 // f2 >>=4;
1313 // int32_t f = 0;
1314 // f<<=1;
1315 // f |= state ? 1:0;
1316 // m->flags2 &= 0x0F;
1317 // m->flags2 |= f<<4;
1318 //if ( state )
1319 // (m->flags2>>4) |= 2;
1320 //else (m->flags2>>4) &= ~2;
1321 break;
1322 }
1323 case MSF_CYCLEINIT:
1324 if ( state )
1325 m->flags3 |= 2;
1326 else m->flags3 &= ~2;
1327 break;
1328 case MSF_IGNOREBOOTS:
1329 if ( state )
1330 m->flags5 |= 2;
1331 else m->flags5 &= ~2;
1332 break;
1333 case MSF_TOGGLERINGS:
1334 if ( state )
1335 m->flags6 |= 64;
1336 else m->flags6 &= ~64;
1337 break;
1338 // Save
1339 case MSF_SAVECONTHERE:
1340 if ( state )
1341 m->flags4 |= 64;
1342 else m->flags4 &= ~64;
1343 break;
1344 case MSF_SAVEONENTRY:
1345 if ( state )
1346 m->flags4 |= 128;
1347 else m->flags4 &= ~128;
1348 break;
1349
1350 case MSF_CONTHERE:
1351 if ( state )
1352 m->flags6 |= 8;
1353 else m->flags6 &= ~8;
1354 break;
1355
1356 case MSF_NOCONTINUEWARP:
1357 if ( state )
1358 m->flags6 |= 16;
1359 else m->flags6 &= ~16;
1360 break;
1361
1362 // FFC
1363 case MSF_WRAPFFC:
1364 if ( state )
1365 m->flags6 |= 128;
1366 else m->flags6 &= ~128;
1367 break;
1368
1369 case MSF_NOCARRYOVERFFC:
1370 if ( state )
1371 m->flags5 |= 128;
1372 else m->flags5 &= ~128;
1373 break;
1374
1375 // Whistle
1376 case MSF_STAIRS:
1377 if ( state )
1378 m->flags |= 16;
1379 else m->flags &= ~16;
1380 break;
1381 case MSF_PALCHANGE:
1382 if ( state )
1383 m->flags7 |= 64;
1384 else m->flags7 &= ~64;
1385 break;
1386 case MSF_DRYLAKE:
1387 if ( state )
1388 m->flags7 |= 128;
1389 else m->flags7 &= ~128;
1390 break;
1391
1392 // Enemies
1393 case MSF_TRAPS_IGNORE_SOLID:
1394 {
1395 //! What the ever love of fuck mate?!
1396 int32_t f = 0;
1397 f<<=2;
1398 f |= state ? 1:0;
1399 m->flags2 &= 0x0F;
1400 m->flags2 |= f<<4;
1401 break;
1402
1403 //! May be wrong : Might be 4>>4 : ~4>>4;?
1404 //if ( state )
1405 // m->(flags2>>4) |= 4;
1406 //else (flags2>>4) &= ~4;
1407 //break;
1408 }
1409 case MSF_ENEMEIS_SECRET:
1410 {
1411 //! What the ever love of fuck mate?!
1412 int32_t f = 0;
1413 f<<=3;
1414 f |= state ? 1:0;
1415 m->flags2 &= 0x0F;
1416 m->flags2 |= f<<4;
1417 break;
1418
1419 //! May be wrong : Might be 8>>4 : ~8>>4;?
1420 //if ( state )
1421 // m->(flags2>>4) |= 8;
1422 //else (flags2>>4) &= ~8;
1423 //break;
1424 }
1425 case MSF_INVISIBLEENEMIES:
1426 if ( state )
1427 m->flags3 |= 4;
1428 else m->flags3 &= ~4;
1429 case MSF_EMELIESALWAYSRETURN:
1430 if ( state )
1431 m->flags3 |= 128;
1432 else m->flags3 &= ~128;
1433 break;
1434 case MSF_ENEMIES_ITEM:
1435 if ( state )
1436 m->flags |= 2;
1437 else m->flags &= ~2;
1438 break;
1439
1440 case MSF_ENEMIES_SECRET_PERM:
1441 if ( state )
1442 m->flags4 |= 16;
1443 else m->flags4 &= ~16;
1444 break;
1445
1446 case MSF_SPAWN_ZORA:
1447 if ( state )
1448 m->enemyflags |= 1;
1449 else m->enemyflags &= ~1;
1450 break;
1451 case MSF_SPAWN_CORNERTRAP:
1452 if ( state )
1453 m->enemyflags |= 2;
1454 else m->enemyflags &= ~2;
1455 break;
1456 case MSF_SPAWN_MIDDLETRAP:
1457 if ( state )
1458 m->enemyflags |= 4;
1459 else m->enemyflags &= ~4;
1460 break;
1461 case MSF_SPAWN_ROCK:
1462 if ( state )
1463 m->enemyflags |= 8;
1464 else m->enemyflags &= ~8;
1465 break;
1466 case MSF_SPAWN_SHOOTER:
1467 if ( state )
1468 m->enemyflags |= 16;
1469 else m->enemyflags &= ~16;
1470 break;
1471
1472 case MSF_RINGLEADER:
1473 if ( state )
1474 m->enemyflags |= 32;
1475 else m->enemyflags &= ~32;
1476 break;
1477 case MSF_ENEMYHASITEM:
1478 if ( state )
1479 m->enemyflags |= 64;
1480 else m->enemyflags &= ~64;
1481 break;
1482 case MSF_ENEMYISBOSS:
1483 if ( state )
1484 m->enemyflags |= 128;
1485 else m->enemyflags &= ~128;
1486 break;
1487
1488 // Misc
1489 case MSF_ALLOW_LADDER:
1490 if ( state )
1491 m->flags |= 32;
1492 else m->flags &= ~32;
1493 break;
1494 case MSF_NO_DIVING:
1495 if ( state )
1496 m->flags5 |= 64;
1497 else m->flags5 &= ~64;
1498 break;
1499
1500 case MSF_LENSEFFECT:
1501 if ( state )
1502 m->flags8 |= 32;
1503 else m->flags8 &= ~32;
1504 break;
1505
1506 case MSF_SFXONENTRY:
1507 if ( state )
1508 m->flags |= 128;
1509 else m->flags &= ~128;
1510 break;
1511
1512
1513 // Custom / Script
1514 case MSF_SCRIPT1:
1515 if ( state )
1516 m->flags8 |= 1;
1517 else m->flags8 &= ~1;
1518 break;
1519 case MSF_SCRIPT2:
1520 if ( state )
1521 m->flags8 |= 2;
1522 else m->flags8 &= ~2;
1523 break;
1524 case MSF_SCRIPT3:
1525 if ( state )
1526 m->flags8 |= 4;
1527 else m->flags8 &= ~4;
1528 break;
1529 case MSF_SCRIPT4:
1530 if ( state )
1531 m->flags8 |= 8;
1532 else m->flags8 &= ~8;
1533 break;
1534 case MSF_SCRIPT5:
1535 if ( state )
1536 m->flags8 |= 16;
1537 else m->flags8 &= ~16;
1538 break;
1539
1540 //This is a dummy proc, but may have been used at one point in older versions.
1541 case MSF_DUMMY_8:
1542 if ( state )
1543 m->flags |= 8;
1544 else m->flags &= ~8;
1545 break;
1546
1547 default: Z_scripterrlog("Illegal flag value (%d) passed to SetMapscreenFlag", flagid);
1548 }
1549 }
1550
1551 int32_t FFScript::get_mapscreenflag_state(mapscr *m, int32_t flagid)
1552 {
1553 switch(flagid)
1554 {
1555 // Room Types
1556 case MSF_INTERIOR:
1557 return (m->flags6&1) ? 1 : 0;
1558 case MSF_DUNGEON:
1559 return (m->flags6&2) ? 1 : 0;
1560 case MSF_SIDEVIEW:
1561 return (m->flags7&8) ? 1 : 0;
1562
1563 // View
1564 case MSF_INVISHERO:
1565 return (m->flags3&8) ? 1 : 0;
1566 case MSF_NOHEROMARKER:
1567 return (m->flags7&16) ? 1 : 0;
1568
1569 case MSF_NOSUBSCREEN:
1570 return (m->flags3&16) ? 1 : 0;
1571 case MSF_NOOFFSET:
1572 return (m->flags3&64) ? 1 : 0;
1573
1574 case MSF_LAYER2BG:
1575 return (m->flags7&2) ? 1 : 0;
1576 case MSF_LAYER3BG:
1577 return (m->flags7&1) ? 1 : 0;
1578 case MSF_DARKROOM:
1579 return (m->flags&4) ? 1 : 0;
1580
1581 // Secrets
1582 case MSF_BLOCKSHUT:
1583 return (m->flags&1) ? 1 : 0;
1584 case MSF_TEMPSECRETS:
1585 return (m->flags5&16) ? 1 : 0;
1586 case MSF_TRIGPERM:
1587 return (m->flags6&4) ? 1 : 0;
1588 case MSF_ALLTRIGFLAGS:
1589 return (m->flags6&32) ? 1 : 0;
1590
1591 // Warp
1592 case MSF_AUTODIRECT:
1593 return (m->flags5&4) ? 1 : 0;
1594 case MSF_SENDSIRECT:
1595 return (m->flags5&8) ? 1 : 0;
1596 case MSF_MAZEPATHS:
1597 return (m->flags&64) ? 1 : 0;
1598
1599 case MSF_MAZEOVERRIDE:
1600 return (m->flags8&64) ? 1 : 0;
1601 case MSF_SPRITECARRY:
1602 return (m->flags3&32) ? 1 : 0;
1603 case MSF_DIRECTTIMEDWARPS:
1604 return (m->flags4&4) ? 1 : 0;
1605 case MSF_SECRETSISABLETIMEWRP:
1606 return (m->flags4&8) ? 1 : 0;
1607
1608 case MSF_RANDOMTIMEDWARP:
1609 return (m->flags5&1) ? 1 : 0;
1610
1611 // Item
1612 case MSF_HOLDUP:
1613 return (m->flags3&1) ? 1 : 0;
1614 case MSF_FALLS:
1615 return (m->flags7&4) ? 1 : 0;
1616
1617 // Combo
1618 case MSF_MIDAIR:
1619 return ((m->flags2>>4)&2) ? 1 : 0;
1620 case MSF_CYCLEINIT:
1621 return (m->flags3&2) ? 1 : 0;
1622 case MSF_IGNOREBOOTS:
1623 return (m->flags5&2) ? 1 : 0;
1624 case MSF_TOGGLERINGS:
1625 return (m->flags6&64) ? 1 : 0;
1626 // Save
1627 case MSF_SAVECONTHERE:
1628 return (m->flags4&64) ? 1 : 0;
1629 case MSF_SAVEONENTRY:
1630 return (m->flags4&128) ? 1 : 0;
1631
1632 case MSF_CONTHERE:
1633 return (m->flags6&8) ? 1 : 0;
1634
1635 case MSF_NOCONTINUEWARP:
1636 return (m->flags6&16) ? 1 : 0;
1637
1638 // FFC
1639 case MSF_WRAPFFC:
1640 return (m->flags6&128) ? 1 : 0;
1641
1642 case MSF_NOCARRYOVERFFC:
1643 return (m->flags5&128) ? 1 : 0;
1644
1645 // Whistle
1646 case MSF_STAIRS:
1647 return (m->flags&16) ? 1 : 0;
1648 case MSF_PALCHANGE:
1649 return (m->flags7&64) ? 1 : 0;
1650 case MSF_DRYLAKE:
1651 return (m->flags7&128) ? 1 : 0;
1652
1653 // Enemies
1654 case MSF_TRAPS_IGNORE_SOLID:
1655 //! May be wrong : Might be 4>>4 : ~4>>4;?
1656 return ((m->flags2>>4)&4) ? 1 : 0;
1657
1658 case MSF_ENEMEIS_SECRET:
1659 //! May be wrong : Might be 8>>4 : ~8>>4;?
1660 return ((m->flags2>>4)&8) ? 1 : 0;
1661
1662 case MSF_ENEMIES_SECRET_PERM:
1663 return (m->flags4&16) ? 1 : 0;
1664
1665 case MSF_SPAWN_ZORA:
1666 return (m->enemyflags&1) ? 1 : 0;
1667
1668 case MSF_SPAWN_CORNERTRAP:
1669 return (m->enemyflags&2) ? 1 : 0;
1670
1671 case MSF_SPAWN_MIDDLETRAP:
1672 return (m->enemyflags&3) ? 1 : 0;
1673
1674 case MSF_SPAWN_ROCK:
1675 return (m->enemyflags&4) ? 1 : 0;
1676
1677 case MSF_SPAWN_SHOOTER:
1678 return (m->enemyflags&16) ? 1 : 0;
1679
1680 case MSF_RINGLEADER:
1681 return (m->enemyflags&32) ? 1 : 0;
1682
1683 case MSF_ENEMYHASITEM:
1684 return (m->enemyflags&64) ? 1 : 0;
1685 case MSF_ENEMYISBOSS:
1686 return (m->enemyflags&128) ? 1 : 0;
1687
1688 case MSF_INVISIBLEENEMIES:
1689 return (m->flags3&4) ? 1 : 0;
1690 case MSF_EMELIESALWAYSRETURN:
1691 return (m->flags3&128) ? 1 : 0;
1692
1693 case MSF_ENEMIES_ITEM:
1694 return (m->flags&2) ? 1 : 0;
1695
1696 // Misc
1697 case MSF_ALLOW_LADDER:
1698 return (m->flags&32) ? 1 : 0;
1699 case MSF_NO_DIVING:
1700 return (m->flags5&64) ? 1 : 0;
1701
1702 case MSF_LENSEFFECT:
1703 return (m->flags8&32) ? 1 : 0;
1704
1705 case MSF_SFXONENTRY:
1706 return (m->flags&128) ? 1 : 0;
1707
1708 //Custom / Script
1709 case MSF_SCRIPT1:
1710 return (m->flags8&1) ? 1 : 0;
1711 case MSF_SCRIPT2:
1712 return (m->flags8&2) ? 1 : 0;
1713 case MSF_SCRIPT3:
1714 return (m->flags8&4) ? 1 : 0;
1715 case MSF_SCRIPT4:
1716 return (m->flags8&8) ? 1 : 0;
1717 case MSF_SCRIPT5:
1718 return (m->flags8&16) ? 1 : 0;
1719
1720 //This is a dummy proc, but may have been used at one point in older versions.
1721 case MSF_DUMMY_8:
1722 return (m->flags&8) ? 1 : 0;
1723
1724
1725 default:
1726 {
1727 Z_scripterrlog("Illegal flag value (%d) passed to GetMapscreenFlag", flagid);
1728 return -1;
1729 }
1730 }
1731 }
1732 */
1733 //ScriptHelper
1734 class SH
1735 {
1736
1737 ///-----------------------------//
1738 // Errors //
1739 ///-----------------------------//
1740
1741 public:
1742
1743 enum __Error
1744 {
1745 _NoError, //OK!
1746 _Overflow, //script array too small
1747 _InvalidPointer, //passed NULL pointer or similar
1748 _OutOfBounds, //library array out of bounds
1749 _InvalidSpriteUID //bad npc, ffc, etc.
1750 };
1751
1752 #define INVALIDARRAY localRAM[0] //localRAM[0] is never used
1753
1754 //only if the player is messing with their pointers...
1755 static ZScriptArray& InvalidError(const int32_t ptr)
1756 {
1757 Z_scripterrlog("Invalid pointer (%i) passed to array (don't change the values of your array pointers)\n", ptr);
1758 return INVALIDARRAY;
1759 }
1760
1761 static void write_stack(const uint32_t stackoffset, const int32_t value)
1762 {
1763 if(stackoffset == 0)
1764 {
1765 Z_scripterrlog("Stack over or underflow, stack pointer = %ld\n", stackoffset);
1766 return;
1767 }
1768
1769 (*stack)[stackoffset] = value;
1770 }
1771
1772 305197487 static int32_t read_stack(const uint32_t stackoffset)
1773 {
1774
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 305197487 times.
305197487 if(stackoffset == 0)
1775 {
1776 Z_scripterrlog("Stack over or underflow, stack pointer = %ld\n", stackoffset);
1777 return -10000;
1778 }
1779
1780 305197487 return (*stack)[stackoffset];
1781 305197487 }
1782
1783 389291543 static INLINE int32_t get_arg(int32_t arg, bool v)
1784 {
1785
2/2
✓ Branch 0 taken 67653446 times.
✓ Branch 1 taken 321638097 times.
389291543 return v ? arg : get_register(arg);
1786 }
1787 };
1788
1789 ///----------------------------//
1790 // Misc. //
1791 ///----------------------------//
1792
1793 //Miscellaneous Helper
1794 class MiscH : public SH
1795 {
1796 public:
1797
1798 };
1799
1800 byte flagpos;
1801 int32_t flagval;
1802 11829344 void clear_ornextflag()
1803 {
1804 11829344 flagpos = 0;
1805 11829344 flagval = 0;
1806 11829344 }
1807 77350033 void ornextflag(bool flag)
1808 {
1809
2/2
✓ Branch 0 taken 75883502 times.
✓ Branch 1 taken 1466531 times.
77350033 if(flag) flagval |= 1<<flagpos;
1810 77350033 ++flagpos;
1811 77350033 }
1812
1813 6637215 int32_t get_screenflags(mapscr *m, int32_t flagset)
1814 {
1815 6637215 clear_ornextflag();
1816
1817
3/11
✓ Branch 0 taken 3733038 times.
✓ Branch 1 taken 2814568 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 89609 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
6637215 switch(flagset)
1818 {
1819 case 0: // Room Type
1820 3733038 ornextflag(m->flags6&1);
1821 3733038 ornextflag(m->flags6&2);
1822 3733038 ornextflag(m->flags7&8);
1823 3733038 break;
1824
1825 case 1: // View
1826 2814568 ornextflag(m->flags3&8);
1827 2814568 ornextflag(m->flags7&16);
1828 2814568 ornextflag(m->flags3&16);
1829 2814568 ornextflag(m->flags3&64);
1830 2814568 ornextflag(m->flags7&2);
1831 2814568 ornextflag(m->flags7&1);
1832 2814568 ornextflag(m->flags&fDARK);
1833 2814568 ornextflag(m->flags9&fDARK_DITHER);
1834 2814568 ornextflag(m->flags9&fDARK_TRANS);
1835 2814568 break;
1836
1837 case 2: // Secrets
1838 ornextflag(m->flags&1);
1839 ornextflag(m->flags5&16);
1840 ornextflag(m->flags6&4);
1841 ornextflag(m->flags6&32);
1842 break;
1843
1844 case 3: // Warp
1845 ornextflag(m->flags5&4);
1846 ornextflag(m->flags5&8);
1847 ornextflag(m->flags&64);
1848 ornextflag(m->flags8&64);
1849 ornextflag(m->flags3&32);
1850 ornextflag(m->flags9&fDISABLE_MIRROR);
1851 break;
1852
1853 case 4: // Item
1854 ornextflag(m->flags3&1);
1855 ornextflag(m->flags7&4);
1856 ornextflag(m->flags8&0x40);
1857 ornextflag(m->flags8&0x80);
1858 ornextflag(m->flags9&0x01);
1859 ornextflag(m->flags9&0x02);
1860 ornextflag(m->flags9&0x04);
1861 break;
1862
1863 case 5: // Combo
1864 ornextflag((m->flags2>>4)&2);
1865 ornextflag(m->flags3&2);
1866 ornextflag(m->flags5&2);
1867 ornextflag(m->flags6&64);
1868 break;
1869
1870 case 6: // Save
1871 ornextflag(m->flags4&64);
1872 ornextflag(m->flags4&128);
1873 ornextflag(m->flags6&8);
1874 ornextflag(m->flags6&16);
1875 break;
1876
1877 case 7: // FFC
1878 ornextflag(m->flags6&128);
1879 ornextflag(m->flags5&128);
1880 break;
1881
1882 case 8: // Whistle
1883 ornextflag(m->flags&16);
1884 ornextflag(m->flags7&64);
1885 ornextflag(m->flags7&128);
1886 break;
1887
1888 case 9: // Misc
1889 89609 ornextflag(m->flags&32);
1890 89609 ornextflag(m->flags5&64);
1891 89609 flagval |= m->flags8<<2;
1892 89609 break;
1893 }
1894
1895 6637215 return flagval*10000;
1896 }
1897
1898 1522143 int32_t get_screeneflags(mapscr *m, int32_t flagset)
1899 {
1900 1522143 clear_ornextflag();
1901
1902
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 1522143 times.
✗ Branch 3 not taken.
1522143 switch(flagset)
1903 {
1904 case 0:
1905 flagval |= m->enemyflags&0x1F;
1906 break;
1907
1908 case 1:
1909 1522143 ornextflag(m->enemyflags&32);
1910 1522143 ornextflag(m->enemyflags&64);
1911 1522143 ornextflag(m->flags3&4);
1912 1522143 ornextflag(m->enemyflags&128);
1913 1522143 ornextflag((m->flags2>>4)&4);
1914 1522143 break;
1915
1916 case 2:
1917 ornextflag(m->flags3&128);
1918 ornextflag(m->flags&2);
1919 ornextflag((m->flags2>>4)&8);
1920 ornextflag(m->flags4&16);
1921 ornextflag(m->flags9&fENEMY_WAVES);
1922 break;
1923 }
1924
1925 1522143 return flagval*10000;
1926 }
1927
1928 1218351 int32_t get_mi(int32_t ref)
1929 {
1930
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1218351 times.
1218351 if(ref >= 0)
1931 return ref - (8*(ref / MAPSCRS));
1932
1/3
✓ Branch 0 taken 1218351 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
1218351 switch(ref)
1933 {
1934 case MAPSCR_TEMP0: case MAPSCR_TEMP1: case MAPSCR_TEMP2: case MAPSCR_TEMP3:
1935 case MAPSCR_TEMP4: case MAPSCR_TEMP5: case MAPSCR_TEMP6:
1936 1218351 return (currmap*MAPSCRSNORMAL)+homescr;
1937 case MAPSCR_SCROLL0: case MAPSCR_SCROLL1: case MAPSCR_SCROLL2: case MAPSCR_SCROLL3:
1938 case MAPSCR_SCROLL4: case MAPSCR_SCROLL5: case MAPSCR_SCROLL6:
1939 return (scrolling_map*MAPSCRSNORMAL)+scrolling_scr;
1940 }
1941 return -1;
1942 1218351 }
1943
1944 ///------------------------------------------------//
1945 // Bounds Checking Functions //
1946 ///------------------------------------------------//
1947
1948 //Bounds Checker
1949 class BC : public SH
1950 {
1951 public:
1952
1953 18740053 static INLINE int32_t checkMapID(const int32_t ID, const char * const str)
1954 {
1955 //return checkBounds(ID, 0, map_count-1, str);
1956
2/4
✓ Branch 0 taken 18740053 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 18740053 times.
18740053 if(ID < 0 || ID > map_count-1)
1957 {
1958 Z_scripterrlog("Invalid value (%i) passed to '%s'\n", ID+1, str);
1959 return _OutOfBounds;
1960 }
1961
1962 18740053 return _NoError;
1963 18740053 }
1964
1965 2871655 static INLINE int32_t checkDMapID(const int32_t ID, const char * const str)
1966 {
1967 2871655 return checkBounds(ID, 0, MAXDMAPS-1, str);
1968 }
1969
1970 81859776 static INLINE int32_t checkComboPos(const int32_t pos, const char * const str)
1971 {
1972 81859776 return checkBoundsPos(pos, 0, 175, str);
1973 }
1974
1975 127663 static INLINE int32_t checkTile(const int32_t pos, const char * const str)
1976 {
1977 127663 return checkBounds(pos, 0, NEWMAXTILES-1, str);
1978 }
1979
1980 2564 static INLINE int32_t checkCombo(const int32_t pos, const char * const str)
1981 {
1982 2564 return checkBounds(pos, 0, MAXCOMBOS-1, str);
1983 }
1984
1985 6076 static INLINE int32_t checkMisc(const int32_t a, const char * const str)
1986 {
1987 6076 return checkBounds(a, 0, 15, str);
1988 }
1989
1990 13992744 static INLINE int32_t checkMisc32(const int32_t a, const char * const str)
1991 {
1992 13992744 return checkBounds(a, 0, 31, str);
1993 }
1994
1995 3839 static INLINE int32_t checkMessage(const int32_t ID, const char * const str)
1996 {
1997 3839 return checkBounds(ID, 0, msg_strings_size-1, str);
1998 }
1999
2000 static INLINE int32_t checkLayer(const int32_t layer, const char * const str)
2001 {
2002 return checkBounds(layer, 0, 6, str);
2003 }
2004
2005 503793134 static INLINE int32_t checkFFC(const int32_t ffc, const char * const str)
2006 {
2007 503793134 return checkBounds(ffc, 0, MAXFFCS-1, str);
2008 }
2009
2010 15641785 static INLINE int32_t checkGuyIndex(const int32_t index, const char * const str)
2011 {
2012 15641785 return checkBoundsOneIndexed(index, 0, guys.Count()-1, str);
2013 }
2014
2015 136832 static INLINE int32_t checkItemIndex(const int32_t index, const char * const str)
2016 {
2017 136832 return checkBoundsOneIndexed(index, 0, items.Count()-1, str);
2018 }
2019
2020 2753647 static INLINE int32_t checkEWeaponIndex(const int32_t index, const char * const str)
2021 {
2022 2753647 return checkBoundsOneIndexed(index, 0, Ewpns.Count()-1, str);
2023 }
2024
2025 1201098 static INLINE int32_t checkLWeaponIndex(const int32_t index, const char * const str)
2026 {
2027 1201098 return checkBoundsOneIndexed(index, 0, Lwpns.Count()-1, str);
2028 }
2029
2030 2363 static INLINE int32_t checkGuyID(const int32_t ID, const char * const str)
2031 {
2032 //return checkBounds(ID, 0, MAXGUYS-1, str); //Can't create NPC ID 0
2033 2363 return checkBounds(ID, 1, MAXGUYS-1, str);
2034 }
2035
2036 77157 static INLINE int32_t checkItemID(const int32_t ID, const char * const str)
2037 {
2038 77157 return checkBounds(ID, 0, MAXITEMS-1, str);
2039 }
2040
2041 209179 static INLINE int32_t checkWeaponID(const int32_t ID, const char * const str)
2042 {
2043 209179 return checkBounds(ID, 0, MAXWPNS-1, str);
2044 }
2045
2046 147223 static INLINE int32_t checkWeaponMiscSprite(const int32_t ID, const char * const str)
2047 {
2048 147223 return checkBounds(ID, 0, MAXWPNS-1, str);
2049 }
2050
2051 170812 static INLINE int32_t checkSFXID(const int32_t ID, const char * const str)
2052 {
2053 170812 return checkBounds(ID, 0, WAV_COUNT-1, str);
2054 }
2055
2056 558625161 static INLINE int32_t checkBounds(const int32_t n, const int32_t boundlow, const int32_t boundup, const char * const funcvar)
2057 {
2058
4/4
✓ Branch 0 taken 558625157 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 229 times.
✓ Branch 3 taken 558624928 times.
558625161 if(n < boundlow || n > boundup)
2059 {
2060 233 Z_scripterrlog("Invalid value (%i) passed to '%s'\n", n, funcvar);
2061 233 return _OutOfBounds;
2062 }
2063
2064 558624928 return _NoError;
2065 558625161 }
2066
2067 81859776 static INLINE int32_t checkBoundsPos(const int32_t n, const int32_t boundlow, const int32_t boundup, const char * const funcvar)
2068 {
2069
3/4
✓ Branch 0 taken 81859776 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1584 times.
✓ Branch 3 taken 81858192 times.
81859776 if(n < boundlow || n > boundup)
2070 {
2071 1584 Z_scripterrlog("Invalid position [%i] used to read to '%s'\n", n, funcvar);
2072 1584 return _OutOfBounds;
2073 }
2074
2075 81858192 return _NoError;
2076 81859776 }
2077
2078 19733362 static INLINE int32_t checkBoundsOneIndexed(const int32_t n, const int32_t boundlow, const int32_t boundup, const char * const funcvar)
2079 {
2080
4/4
✓ Branch 0 taken 19719599 times.
✓ Branch 1 taken 13763 times.
✓ Branch 2 taken 74 times.
✓ Branch 3 taken 19719525 times.
19733362 if(n < boundlow || n > boundup)
2081 {
2082 13837 Z_scripterrlog("Invalid value (%i) passed to '%s'\n", n+1, funcvar);
2083 13837 return _OutOfBounds;
2084 }
2085
2086 19719525 return _NoError;
2087 19733362 }
2088
2089 1634188862 static INLINE int32_t checkUserArrayIndex(const int32_t index, const dword size, const bool neg = false)
2090 {
2091
2092
6/6
✓ Branch 0 taken 40454147 times.
✓ Branch 1 taken 1593734715 times.
✓ Branch 2 taken 1633555781 times.
✓ Branch 3 taken 633081 times.
✓ Branch 4 taken 7038 times.
✓ Branch 5 taken 1633548743 times.
1634188862 if(index < (neg ? -int32_t(size) : 0) || index >= int32_t(size))
2093 {
2094 640119 Z_scripterrlog("Invalid index (%ld) to local array of size %ld\n", index, size);
2095 640119 return _OutOfBounds;
2096 }
2097
2098 1633548743 return _NoError;
2099 1634188862 }
2100 };
2101
2102 ///------------------------------------------------//
2103 // Pointer Handling Functions //
2104 ///------------------------------------------------//
2105 //MUST call AND check load functions before trying to use other functions
2106
2107
2108
2109
2110 //Guy Helper
2111 class GuyH : public SH
2112 {
2113
2114 public:
2115 78110851 static int32_t loadNPC(const int32_t eid, const char * const funcvar)
2116 {
2117
2/2
✓ Branch 0 taken 78110704 times.
✓ Branch 1 taken 147 times.
78110851 if ( !eid )
2118 {
2119 //can never be zero?
2120 147 Z_scripterrlog("The npc pointer used for %s is NULL or uninitialised.", funcvar);
2121 147 return _InvalidSpriteUID;
2122 }
2123 78110704 tempenemy = (enemy *) guys.getByUID(eid);
2124
2125
2/2
✓ Branch 0 taken 5901 times.
✓ Branch 1 taken 78104803 times.
78110704 if(tempenemy == NULL)
2126 {
2127 5901 Z_scripterrlog("Invalid NPC with UID %ld passed to %s\nNPCs on screen have UIDs ", eid, funcvar);
2128
2129
2/2
✓ Branch 0 taken 13743 times.
✓ Branch 1 taken 5901 times.
19644 for(word i = 0; i < guys.Count(); i++)
2130 13743 Z_scripterrlog("%ld ", guys.spr(i)->getUID());
2131
2132 5901 Z_scripterrlog("\n");
2133 5901 return _InvalidSpriteUID;
2134 }
2135
2136 78104803 return _NoError;
2137 78110851 }
2138
2139 73297448 static INLINE enemy *getNPC()
2140 {
2141 73297448 return tempenemy;
2142 }
2143
2144 // Currently only used in a context where the enemy is known to be valid,
2145 // so there's no need to print an error
2146 2 static int32_t getNPCIndex(const int32_t eid)
2147 {
2148
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 for(word i = 0; i < guys.Count(); i++)
2149 {
2150
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(guys.spr(i)->getUID() == eid)
2151 2 return i;
2152 }
2153
2154 return -1;
2155 2 }
2156
2157 6431340 static int32_t getNPCDMisc(const byte a)
2158 {
2159
12/33
✓ Branch 0 taken 2128 times.
✓ Branch 1 taken 9365 times.
✓ Branch 2 taken 1308 times.
✓ Branch 3 taken 5650 times.
✓ Branch 4 taken 874 times.
✓ Branch 5 taken 742 times.
✓ Branch 6 taken 107 times.
✓ Branch 7 taken 64 times.
✓ Branch 8 taken 391 times.
✓ Branch 9 taken 383 times.
✓ Branch 10 taken 3262599 times.
✓ Branch 11 taken 3147729 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
6431340 switch(a)
2160 {
2161 2128 case 0: return tempenemy->dmisc1;
2162 9365 case 1: return tempenemy->dmisc2;
2163 1308 case 2: return tempenemy->dmisc3;
2164 5650 case 3: return tempenemy->dmisc4;
2165 874 case 4: return tempenemy->dmisc5;
2166 742 case 5: return tempenemy->dmisc6;
2167 107 case 6: return tempenemy->dmisc7;
2168 64 case 7: return tempenemy->dmisc8;
2169 391 case 8: return tempenemy->dmisc9;
2170 383 case 9: return tempenemy->dmisc10;
2171 3262599 case 10: return tempenemy->dmisc11;
2172 3147729 case 11: return tempenemy->dmisc12;
2173 case 12: return tempenemy->dmisc13;
2174 case 13: return tempenemy->dmisc14;
2175 case 14: return tempenemy->dmisc15;
2176 case 15: return tempenemy->dmisc16;
2177 case 16: return tempenemy->dmisc17;
2178 case 17: return tempenemy->dmisc18;
2179 case 18: return tempenemy->dmisc19;
2180 case 19: return tempenemy->dmisc20;
2181 case 20: return tempenemy->dmisc21;
2182 case 21: return tempenemy->dmisc22;
2183 case 22: return tempenemy->dmisc23;
2184 case 23: return tempenemy->dmisc24;
2185 case 24: return tempenemy->dmisc25;
2186 case 25: return tempenemy->dmisc26;
2187 case 26: return tempenemy->dmisc27;
2188 case 27: return tempenemy->dmisc28;
2189 case 28: return tempenemy->dmisc29;
2190 case 29: return tempenemy->dmisc30;
2191 case 30: return tempenemy->dmisc31;
2192 case 31: return tempenemy->dmisc32;
2193 }
2194
2195 return 0;
2196 6431340 }
2197
2198 4018546 static bool hasHero()
2199 {
2200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4018546 times.
4018546 if(tempenemy->family == eeWALLM)
2201 return ((eWallM *) tempenemy)->hashero;
2202
2203
2/2
✓ Branch 0 taken 216104 times.
✓ Branch 1 taken 3802442 times.
4018546 if(tempenemy->family == eeWALK)
2204 216104 return ((eStalfos *) tempenemy)->hashero;
2205
2206 3802442 return false;
2207 4018546 }
2208
2209 3669986 static int32_t getMFlags()
2210 {
2211 3669986 clear_ornextflag();
2212 3669986 flagpos = 5;
2213 // Must be in the same order as in the Enemy Editor pane
2214 3669986 ornextflag(tempenemy->flags&(lens_only));
2215 3669986 ornextflag(tempenemy->flags2&(guy_flashing));
2216 3669986 ornextflag(tempenemy->flags2&(guy_blinking));
2217 3669986 ornextflag(tempenemy->flags2&(guy_transparent));
2218 3669986 ornextflag(tempenemy->flags&(inv_front));
2219 3669986 ornextflag(tempenemy->flags&(inv_left));
2220 3669986 ornextflag(tempenemy->flags&(inv_right));
2221 3669986 ornextflag(tempenemy->flags&(inv_back));
2222 3669986 ornextflag(tempenemy->flags&(guy_bkshield));
2223 3669986 return (tempenemy->flags&0x1F) | flagval;
2224 }
2225
2226 16353 static INLINE void clearTemp()
2227 {
2228 16353 tempenemy = NULL;
2229 16353 }
2230
2231 private:
2232
2233 static enemy *tempenemy;
2234 };
2235
2236 enemy *GuyH::tempenemy = NULL;
2237
2238 //Item Helper
2239 class ItemH : public SH
2240 {
2241
2242 public:
2243 static int32_t loadItem(const int32_t iid, const char * const funcvar)
2244 {
2245 if ( !iid )
2246 {
2247 //can never be zero?
2248 Z_scripterrlog("The item pointer used for %s is NULL or uninitialised.", funcvar);
2249 return _InvalidSpriteUID;
2250 }
2251
2252 tempitem = (item *) items.getByUID(iid);
2253
2254 if(tempitem == NULL)
2255 {
2256 Z_scripterrlog("Invalid item with UID %ld passed to %s\nItems on screen have UIDs ", iid, funcvar);
2257
2258 for(word i = 0; i < items.Count(); i++)
2259 Z_scripterrlog("%ld ", items.spr(i)->getUID());
2260
2261 Z_scripterrlog("\n");
2262 return _InvalidSpriteUID;
2263 }
2264
2265 return _NoError;
2266 }
2267
2268 2645 static int32_t getItemIndex(const int32_t iid)
2269 {
2270
1/2
✓ Branch 0 taken 3957 times.
✗ Branch 1 not taken.
3957 for(word i = 0; i < items.Count(); i++)
2271 {
2272
2/2
✓ Branch 0 taken 2645 times.
✓ Branch 1 taken 1312 times.
3957 if(items.spr(i)->getUID() == iid)
2273 2645 return i;
2274 1312 }
2275
2276 return -1;
2277 2645 }
2278
2279 static INLINE item* getItem()
2280 {
2281 return tempitem;
2282 }
2283
2284 16353 static INLINE void clearTemp()
2285 {
2286 16353 tempitem = NULL;
2287 16353 }
2288
2289 private:
2290
2291 static item *tempitem;
2292 };
2293
2294 item *ItemH::tempitem = NULL;
2295
2296 //LWeapon Helper
2297 class LwpnH : public SH
2298 {
2299
2300 public:
2301
2302
2303 static defWpnSprite getDefWeaponSprite(weapon *wp)
2304 {
2305 switch(wp->id)
2306 {
2307 case wNone: return ws_0;
2308 case wSword: return ws_0;
2309 case wBeam: return wsBeam;
2310 case wBrang : return wsBrang;
2311 case wBomb: return wsBomb;
2312 case wSBomb: return wsSBomb;
2313 case wLitBomb: return wsBombblast;
2314 case wLitSBomb: return wsBombblast;
2315 case wArrow: return wsArrow;
2316 case wFire: return wsFire;
2317 case wWhistle: return wsUnused45;
2318 case wBait: return wsBait;
2319 case wWand: return wsWandHandle;
2320 case wMagic: return wsMagic;
2321 case wCatching: return wsUnused45;
2322 case wWind: return wsWind;
2323 case wRefMagic: return wsRefMagic;
2324 case wRefFireball: return wsRefFireball;
2325 case wRefRock: return wsRock;
2326 case wHammer: return wsHammer;
2327 case wHookshot: return wsHookshotHead;
2328 case wHSHandle: return wsHookshotHandle;
2329 case wHSChain: return wsHookshotChainH;
2330 case wSSparkle: return wsSilverSparkle;
2331 case wFSparkle: return wsGoldSparkle;
2332 case wSmack: return wsHammerSmack;
2333 case wPhantom: return wsUnused45;
2334 case wCByrna: return wsByrnaCane;
2335 case wRefBeam: return wsRefBeam;
2336 case wStomp: return wsUnused45;
2337 case lwMax: return wsUnused45;
2338 case wScript1:
2339 case wScript2:
2340 case wScript3:
2341 case wScript4:
2342 case wScript5:
2343 case wScript6:
2344 case wScript7:
2345 case wScript8:
2346 case wScript9:
2347 case wScript10: return ws_0;
2348 case wIce: return wsIce; //new
2349 case wFlame: return wsEFire2; //new
2350 //not implemented; t/b/a
2351 case wSound:
2352 case wThrown:
2353 case wPot:
2354 case wLit:
2355 case wBombos:
2356 case wEther:
2357 case wQuake:
2358 case wSword180:
2359 case wSwordLA: return wsUnused45;
2360
2361 case ewFireball: return wsFireball2;
2362 case ewArrow: return wsEArrow;
2363 case ewBrang: return wsBrang;
2364 case ewSword: return wsEBeam;
2365 case ewRock: return wsRock;
2366 case ewMagic: return wsEMagic;
2367 case ewBomb: return wsEBomb;
2368 case ewSBomb: return wsESbomb;
2369 case ewLitBomb: return wsEBombblast;
2370 case ewLitSBomb: return wsESbombblast;
2371 case ewFireTrail: return wsEFiretrail;
2372 case ewFlame: return wsEFire;
2373 case ewWind: return wsEWind;
2374 case ewFlame2: return wsEFire2;
2375 case ewFlame2Trail: return wsEFiretrail2;
2376 case ewIce: return wsIce;
2377 case ewFireball2: return wsFireball2;
2378 default: return wsUnused45;
2379 }
2380 };
2381
2382 15079 static int32_t loadWeapon(const int32_t wid, const char * const funcvar)
2383 {
2384
1/2
✓ Branch 0 taken 15079 times.
✗ Branch 1 not taken.
15079 if ( !wid )
2385 {
2386 //can never be zero?
2387 Z_scripterrlog("The lweapon pointer used for %s is NULL or uninitialised.", funcvar);
2388 return _InvalidSpriteUID;
2389 }
2390 15079 tempweapon = (weapon *) Lwpns.getByUID(wid);
2391
2392
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15079 times.
15079 if(tempweapon == NULL)
2393 {
2394 Z_scripterrlog("Invalid lweapon with UID %ld passed to %s\nLWeapons on screen have UIDs ", wid, funcvar);
2395
2396 for(word i = 0; i < Lwpns.Count(); i++)
2397 Z_scripterrlog("%ld ", Lwpns.spr(i)->getUID());
2398
2399 Z_scripterrlog("\n");
2400 return _InvalidSpriteUID;
2401 }
2402
2403 15079 return _NoError;
2404 15079 }
2405
2406 370531 static int32_t getLWeaponIndex(const int32_t lwid)
2407 {
2408
1/2
✓ Branch 0 taken 4133818 times.
✗ Branch 1 not taken.
4133818 for(word i = 0; i < Lwpns.Count(); i++)
2409 {
2410
2/2
✓ Branch 0 taken 370531 times.
✓ Branch 1 taken 3763287 times.
4133818 if(Lwpns.spr(i)->getUID() == lwid)
2411 370531 return i;
2412 3763287 }
2413
2414 return -1;
2415 370531 }
2416
2417 15079 static INLINE weapon *getWeapon()
2418 {
2419 15079 return tempweapon;
2420 }
2421
2422 16353 static INLINE void clearTemp()
2423 {
2424 16353 tempweapon = NULL;
2425 16353 }
2426
2427 private:
2428
2429 static weapon *tempweapon;
2430 };
2431
2432 weapon *LwpnH::tempweapon = NULL;
2433
2434 //EWeapon Helper
2435 class EwpnH : public SH
2436 {
2437
2438 public:
2439
2440 defWpnSprite getDefWeaponSprite(weapon *wp)
2441 {
2442 switch(wp->id)
2443 {
2444 case wNone: return ws_0;
2445 case wSword: return ws_0;
2446 case wBeam: return wsBeam;
2447 case wBrang : return wsBrang;
2448 case wBomb: return wsBomb;
2449 case wSBomb: return wsSBomb;
2450 case wLitBomb: return wsBombblast;
2451 case wLitSBomb: return wsBombblast;
2452 case wArrow: return wsArrow;
2453 case wFire: return wsFire;
2454 case wWhistle: return wsUnused45;
2455 case wBait: return wsBait;
2456 case wWand: return wsWandHandle;
2457 case wMagic: return wsMagic;
2458 case wCatching: return wsUnused45;
2459 case wWind: return wsWind;
2460 case wRefMagic: return wsRefMagic;
2461 case wRefFireball: return wsRefFireball;
2462 case wRefRock: return wsRock;
2463 case wHammer: return wsHammer;
2464 case wHookshot: return wsHookshotHead;
2465 case wHSHandle: return wsHookshotHandle;
2466 case wHSChain: return wsHookshotChainH;
2467 case wSSparkle: return wsSilverSparkle;
2468 case wFSparkle: return wsGoldSparkle;
2469 case wSmack: return wsHammerSmack;
2470 case wPhantom: return wsUnused45;
2471 case wCByrna: return wsByrnaCane;
2472 case wRefBeam: return wsRefBeam;
2473 case wStomp: return wsUnused45;
2474 case lwMax: return wsUnused45;
2475 case wScript1:
2476 case wScript2:
2477 case wScript3:
2478 case wScript4:
2479 case wScript5:
2480 case wScript6:
2481 case wScript7:
2482 case wScript8:
2483 case wScript9:
2484 case wScript10: return ws_0;
2485 case wIce: return wsIce; //new
2486 case wFlame: return wsEFire2; //new
2487 //not implemented; t/b/a
2488 case wSound:
2489 case wThrown:
2490 case wPot:
2491 case wLit:
2492 case wBombos:
2493 case wEther:
2494 case wQuake:
2495 case wSword180:
2496 case wSwordLA: return wsUnused45;
2497
2498 case ewFireball: return wsFireball2;
2499 case ewArrow: return wsEArrow;
2500 case ewBrang: return wsBrang;
2501 case ewSword: return wsEBeam;
2502 case ewRock: return wsRock;
2503 case ewMagic: return wsEMagic;
2504 case ewBomb: return wsEBomb;
2505 case ewSBomb: return wsESbomb;
2506 case ewLitBomb: return wsEBombblast;
2507 case ewLitSBomb: return wsESbombblast;
2508 case ewFireTrail: return wsEFiretrail;
2509 case ewFlame: return wsEFire;
2510 case ewWind: return wsEWind;
2511 case ewFlame2: return wsEFire2;
2512 case ewFlame2Trail: return wsEFiretrail2;
2513 case ewIce: return wsIce;
2514 case ewFireball2: return wsFireball2;
2515 default: return wsUnused45;
2516 }
2517 };
2518
2519 132144 static int32_t loadWeapon(const int32_t wid, const char * const funcvar)
2520 {
2521
1/2
✓ Branch 0 taken 132144 times.
✗ Branch 1 not taken.
132144 if ( !wid )
2522 {
2523 //can never be zero?
2524 Z_scripterrlog("The eweapon pointer used for %s is NULL or uninitialised.", funcvar);
2525 return _InvalidSpriteUID;
2526 }
2527 132144 tempweapon = (weapon *) Ewpns.getByUID(wid);
2528
2529
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132144 times.
132144 if(tempweapon == NULL)
2530 {
2531 Z_scripterrlog("Invalid eweapon with UID %ld passed to %s\nEWeapons on screen have UIDs ", wid, funcvar);
2532
2533 for(word i = 0; i < Ewpns.Count(); i++)
2534 Z_scripterrlog("%ld ", Ewpns.spr(i)->getUID());
2535
2536 Z_scripterrlog("\n");
2537 return _InvalidSpriteUID;
2538 }
2539
2540 132144 return _NoError;
2541 132144 }
2542
2543 119542 static int32_t getEWeaponIndex(const int32_t ewid)
2544 {
2545
1/2
✓ Branch 0 taken 490280 times.
✗ Branch 1 not taken.
490280 for(word i = 0; i < Ewpns.Count(); i++)
2546 {
2547
2/2
✓ Branch 0 taken 119542 times.
✓ Branch 1 taken 370738 times.
490280 if(Ewpns.spr(i)->getUID() == ewid)
2548 119542 return i;
2549 370738 }
2550
2551 return -1;
2552 119542 }
2553
2554 132144 static INLINE weapon *getWeapon()
2555 {
2556 132144 return tempweapon;
2557 }
2558
2559 16353 static INLINE void clearTemp()
2560 {
2561 16353 tempweapon = NULL;
2562 16353 }
2563
2564 private:
2565
2566 static weapon *tempweapon;
2567 };
2568
2569 weapon *EwpnH::tempweapon = NULL;
2570
2571 16353 void clearScriptHelperData()
2572 {
2573 16353 GuyH::clearTemp();
2574 16353 ItemH::clearTemp();
2575 16353 LwpnH::clearTemp();
2576 16353 EwpnH::clearTemp();
2577 16353 }
2578
2579 ///---------------------------------------------//
2580 // Array Helper Functions //
2581 ///---------------------------------------------//
2582
2583 class ArrayManager
2584 {
2585 public:
2586 ArrayManager(int32_t ptr, bool neg);
2587 ArrayManager(int32_t ptr);
2588
2589 int32_t get(int32_t indx) const;
2590 void set(int32_t indx, int32_t val);
2591 int32_t size() const;
2592
2593 bool resize(size_t newsize);
2594
2595 1941840 bool invalid() const {return _invalid;}
2596 bool internal() const {return !_invalid && !aptr;}
2597
2598 std::string asString(std::function<char const*(int32_t)> formatter, const size_t& limit) const;
2599
2600 bool negAccess;
2601 private:
2602 int32_t ptr;
2603 ZScriptArray* aptr;
2604 bool _invalid;
2605 };
2606
2607 //Array Helper
2608 class ArrayH : public SH
2609 {
2610 public:
2611 294114397 static size_t getSize(const int32_t ptr)
2612 {
2613 294114397 ArrayManager am(ptr);
2614 294114397 return am.size();
2615 }
2616
2617 //Can't you get the std::string and then check its length?
2618 static int32_t strlen(const int32_t ptr)
2619 {
2620 ArrayManager am(ptr);
2621 if (am.invalid())
2622 return -1;
2623
2624 word count;
2625 size_t sz = am.size();
2626 for(count = 0; BC::checkUserArrayIndex(count, sz) == _NoError
2627 && am.get(count) != '\0'; count++);
2628
2629 return count;
2630 }
2631
2632 //Returns values of a zscript array as an std::string.
2633 1690177 static void getString(const int32_t ptr, string &str, dword num_chars = ZSCRIPT_MAX_STRING_CHARS, dword offset = 0)
2634 {
2635 1690177 ArrayManager am(ptr);
2636
2637
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1690172 times.
1690177 if(am.invalid())
2638 {
2639 5 str.clear();
2640 5 return;
2641 }
2642
2643 1690172 str.clear();
2644 1690172 size_t sz = am.size();
2645
5/6
✓ Branch 0 taken 19714787 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1690172 times.
✓ Branch 3 taken 18024615 times.
✓ Branch 4 taken 1690172 times.
✓ Branch 5 taken 18024615 times.
19714787 for(word i = offset; BC::checkUserArrayIndex(i, sz) == _NoError && am.get(i) != '\0' && num_chars != 0; i++)
2646 {
2647 18024615 int32_t c = am.get(i) / 10000;
2648
1/2
✓ Branch 0 taken 18024615 times.
✗ Branch 1 not taken.
18024615 if(char(c) != c)
2649 {
2650 Z_scripterrlog("Illegal char value (%d) at position [%d] in string pointer %d\n", c, i, ptr);
2651 Z_scripterrlog("Value of invalid char will overflow.\n");
2652 }
2653 18024615 str += char(c);
2654 18024615 --num_chars;
2655 18024615 }
2656 1690177 }
2657
2658 //Used for issues where reading the ZScript array floods the console with errors 'Accessing array index [12] size of 12.
2659 //Happens with Quad3D and some other functions, and I have no clue why. -Z ( 28th April, 2019 )
2660 //Like getString but for an array of longs instead of chars. *(arrayPtr is not checked for validity)
2661 static void getValues2(const int32_t ptr, int32_t* arrayPtr, dword num_values, dword offset = 0) //a hack -Z
2662 {
2663 ArrayManager am(ptr);
2664
2665 if(am.invalid())
2666 return;
2667
2668 size_t sz = am.size();
2669 for(word i = offset; BC::checkUserArrayIndex(i, sz+1) == _NoError && num_values != 0; i++)
2670 {
2671 arrayPtr[i] = (am.get(i) / 10000);
2672 num_values--;
2673 }
2674 }
2675
2676 //Like getString but for an array of longs instead of chars. *(arrayPtr is not checked for validity)
2677 static void getValues(const int32_t ptr, int32_t* arrayPtr, dword num_values, dword offset = 0)
2678 {
2679 ArrayManager am(ptr);
2680
2681 if (am.invalid())
2682 return;
2683 size_t sz = am.size();
2684 for(word i = offset; BC::checkUserArrayIndex(i, sz) == _NoError && num_values != 0; i++)
2685 {
2686 arrayPtr[i] = (am.get(i) / 10000);
2687 num_values--;
2688 }
2689 }
2690
2691 static void copyValues(const int32_t ptr, const int32_t ptr2, size_t num_values)
2692 {
2693 ArrayManager am1(ptr), am2(ptr2);
2694 if(am1.invalid() || am2.invalid())
2695 return;
2696 size_t sz = std::min(am1.size(),am2.size());
2697 for(word i = 0; (BC::checkUserArrayIndex(i, sz) == _NoError) && num_values != 0; i++)
2698 {
2699 am1.set(i,am2.get(i));
2700 num_values--;
2701 }
2702 }
2703 //Get element from array
2704 1046590308 static INLINE int32_t getElement(const int32_t ptr, int32_t offset,
2705 const bool neg = false)
2706 {
2707 1046590308 ArrayManager am(ptr,neg);
2708 1046590308 return am.get(offset);
2709 }
2710
2711 //Set element in array
2712 518522412 static INLINE void setElement(const int32_t ptr, int32_t offset,
2713 const int32_t value, const bool neg = false)
2714 {
2715 518522412 ArrayManager am(ptr,neg);
2716 518522412 am.set(offset,value);
2717 518522412 }
2718
2719 //Puts values of a zscript array into a client <type> array. returns 0 on success. Overloaded
2720 template <typename T>
2721 static int32_t getArray(const int32_t ptr, T *refArray)
2722 {
2723 return getArray(ptr, getSize(ptr), 0, 0, 0, refArray);
2724 }
2725
2726 template <typename T>
2727 static int32_t getArray(const int32_t ptr, const word size, T *refArray)
2728 {
2729 return getArray(ptr, size, 0, 0, 0, refArray);
2730 }
2731
2732 template <typename T>
2733 static int32_t getArray(const int32_t ptr, const word size, word userOffset, const word userStride, const word refArrayOffset, T *refArray)
2734 {
2735 ArrayManager am(ptr);
2736
2737 if (am.invalid())
2738 return _InvalidPointer;
2739
2740 word j = 0, k = userStride;
2741
2742 size_t sz = am.size();
2743 for(word i = 0; j < size; i++)
2744 {
2745 if(i >= sz)
2746 return _Overflow;
2747
2748 if(userOffset-- > 0)
2749 continue;
2750
2751 if(k > 0)
2752 k--;
2753 else if(BC::checkUserArrayIndex(i, sz) == _NoError)
2754 {
2755 refArray[j + refArrayOffset] = T(am.get(i));
2756 k = userStride;
2757 j++;
2758 }
2759 }
2760
2761 return _NoError;
2762 }
2763
2764 250587 static int32_t setArray(const int32_t ptr, string const& s2)
2765 {
2766 250587 ArrayManager am(ptr);
2767
2768
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 250587 times.
250587 if (am.invalid())
2769 return _InvalidPointer;
2770
2771 word i;
2772
2773 250587 size_t sz = am.size();
2774
2/2
✓ Branch 0 taken 5558886 times.
✓ Branch 1 taken 250539 times.
5809425 for(i = 0; i < s2.size(); i++)
2775 {
2776
2/2
✓ Branch 0 taken 5558838 times.
✓ Branch 1 taken 48 times.
5558886 if(i >= sz)
2777 {
2778 48 am.set(sz-1,'\0');
2779 48 return _Overflow;
2780 }
2781
2782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5558838 times.
5558838 if(BC::checkUserArrayIndex(i, sz) == _NoError)
2783 5558838 am.set(i,s2[i] * 10000);
2784 5558838 }
2785
2786
1/2
✓ Branch 0 taken 250539 times.
✗ Branch 1 not taken.
250539 if(BC::checkUserArrayIndex(i, sz) == _NoError)
2787 250539 am.set(i,'\0');
2788
2789 250539 return _NoError;
2790 250587 }
2791
2792 //Puts values of a client <type> array into a zscript array. returns 0 on success. Overloaded
2793 template <typename T>
2794 302 static int32_t setArray(const int32_t ptr, const word size, T *refArray, bool x10k = true)
2795 {
2796 302 return setArray(ptr, size, 0, 0, 0, refArray, x10k);
2797 }
2798
2799 template <typename T>
2800 302 static int32_t setArray(const int32_t ptr, const word size, word userOffset, const word userStride, const word refArrayOffset, T *refArray, bool x10k = true)
2801 {
2802 302 ArrayManager am(ptr);
2803
2804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 302 times.
302 if (am.invalid())
2805 return _InvalidPointer;
2806
2807 302 word j = 0, k = userStride;
2808 302 size_t sz = am.size();
2809
2/2
✓ Branch 0 taken 1594 times.
✓ Branch 1 taken 302 times.
1896 for(word i = 0; j < size; i++)
2810 {
2811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1594 times.
1594 if(i >= sz)
2812 return _Overflow; //Resize?
2813
2814
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1594 times.
1594 if (userOffset > 0)
2815 {
2816 --userOffset;
2817 continue;
2818 }
2819
2820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1594 times.
1594 if(k > 0)
2821 k--;
2822
1/2
✓ Branch 0 taken 1594 times.
✗ Branch 1 not taken.
1594 else if(BC::checkUserArrayIndex(i, sz) == _NoError)
2823 {
2824 1594 am.set(i,int32_t(refArray[j + refArrayOffset]) * (x10k ? 10000 : 1));
2825 1594 k = userStride;
2826 1594 j++;
2827 1594 }
2828 1594 }
2829
2830 302 return _NoError;
2831 302 }
2832 };
2833
2834 1861168957 ArrayManager::ArrayManager(int32_t ptr, bool neg) : ptr(ptr), negAccess(neg)
2835 {
2836 1861168957 _invalid = false;
2837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1861168957 times.
1861168957 if(ptr >= INTARR_OFFS)
2838 {
2839 aptr = nullptr;
2840 if(sz_int_arr(ptr) < 0)
2841 _invalid = true;
2842 }
2843
2/2
✓ Branch 0 taken 1861168314 times.
✓ Branch 1 taken 643 times.
1861168957 else if(ptr == 0)
2844 {
2845 643 aptr = &INVALIDARRAY;
2846 643 _invalid = true;
2847 643 }
2848
1/2
✓ Branch 0 taken 1861168314 times.
✗ Branch 1 not taken.
1861168314 else if(ptr < 0) //An object array?
2849 {
2850 int32_t objptr = -ptr;
2851 auto it = objectRAM.find(objptr);
2852 if(it == objectRAM.end())
2853 {
2854 aptr = &INVALIDARRAY;
2855 _invalid = true;
2856 }
2857 else aptr = &(it->second);
2858 }
2859
2/2
✓ Branch 0 taken 1600950828 times.
✓ Branch 1 taken 260217486 times.
1861168314 else if(ptr >= NUM_ZSCRIPT_ARRAYS) //Then it's a global
2860 {
2861 1600950828 dword gptr = ptr - NUM_ZSCRIPT_ARRAYS;
2862
2863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1600950828 times.
1600950828 if(gptr > game->globalRAM.size())
2864 {
2865 aptr = &INVALIDARRAY;
2866 _invalid = true;
2867 }
2868 1600950828 else aptr = &(game->globalRAM[gptr]);
2869 1600950828 }
2870 else
2871 {
2872
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 260217486 times.
260217486 if(localRAM[ptr].Size() == 0)
2873 {
2874 aptr = &INVALIDARRAY;
2875 _invalid = true;
2876 }
2877 260217486 else aptr = &(localRAM[ptr]);
2878 }
2879
2/2
✓ Branch 0 taken 1861168314 times.
✓ Branch 1 taken 643 times.
1861168957 if(_invalid)
2880 {
2881 643 Z_scripterrlog("Invalid pointer (%i) passed to array "
2882 643 "(don't change the values of your array pointers)\n", ptr);
2883 643 }
2884 1861168957 }
2885 296056237 ArrayManager::ArrayManager(int32_t ptr) : ArrayManager(ptr,can_neg_array){}
2886
2887 1084329838 int32_t ArrayManager::get(int32_t indx) const
2888 {
2889
2/2
✓ Branch 0 taken 165 times.
✓ Branch 1 taken 1084329673 times.
1084329838 if(_invalid) return -10000;
2890 1084329673 int32_t sz = size();
2891
1/2
✓ Branch 0 taken 1084329673 times.
✗ Branch 1 not taken.
1084329673 if(aptr)
2892 {
2893
2/2
✓ Branch 0 taken 1083696259 times.
✓ Branch 1 taken 633414 times.
1084329673 if(BC::checkUserArrayIndex(indx, sz, negAccess) == SH::_NoError)
2894 {
2895
1/2
✓ Branch 0 taken 1083696259 times.
✗ Branch 1 not taken.
1083696259 if(indx < 0)
2896 indx += sz; //[-1] becomes [size-1] -Em
2897 1083696259 return (*aptr)[indx];
2898 }
2899 633414 }
2900 else //internal special array
2901 {
2902 if(sz >= 0 && BC::checkUserArrayIndex(indx, sz, negAccess) == SH::_NoError)
2903 {
2904 if(indx < 0)
2905 indx += sz; //[-1] becomes [size-1] -Em
2906 return get_int_arr(ptr, indx);
2907 }
2908 }
2909 633414 return -10000;
2910 1084329838 }
2911 524333431 void ArrayManager::set(int32_t indx, int32_t val)
2912 {
2913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 524333431 times.
524333431 if(_invalid) return;
2914 524333431 int32_t sz = size();
2915
1/2
✓ Branch 0 taken 524333431 times.
✗ Branch 1 not taken.
524333431 if(aptr)
2916 {
2917
2/2
✓ Branch 0 taken 524326726 times.
✓ Branch 1 taken 6705 times.
524333431 if(BC::checkUserArrayIndex(indx, sz, negAccess) == SH::_NoError)
2918 {
2919
1/2
✓ Branch 0 taken 524326726 times.
✗ Branch 1 not taken.
524326726 if(indx < 0)
2920 indx += sz; //[-1] becomes [size-1] -Em
2921 524326726 (*aptr)[indx] = val;
2922 524326726 }
2923 524333431 }
2924 else //internal special array
2925 {
2926 if(sz >= 0 && BC::checkUserArrayIndex(indx, sz, negAccess) == SH::_NoError)
2927 {
2928 if(indx < 0)
2929 indx += sz; //[-1] becomes [size-1] -Em
2930 set_int_arr(ptr, indx, val);
2931 }
2932 }
2933 524333431 }
2934 1904718578 int32_t ArrayManager::size() const
2935 {
2936
2/2
✓ Branch 0 taken 473 times.
✓ Branch 1 taken 1904718105 times.
1904718578 if(_invalid) return -1;
2937
1/2
✓ Branch 0 taken 1904718105 times.
✗ Branch 1 not taken.
1904718105 if(aptr)
2938 1904718105 return aptr->Size();
2939 else // Internal special
2940 {
2941 int32_t sz = sz_int_arr(ptr);
2942 if(sz < 0)
2943 return -1;
2944 return sz;
2945 }
2946 1904718578 }
2947
2948 bool ArrayManager::resize(size_t newsize)
2949 {
2950 if(_invalid) return false;
2951 if(!aptr)
2952 {
2953 Z_scripterrlog("Special internal array '%d' not valid for operation 'Resize'\n", ptr);
2954 return false;
2955 }
2956 aptr->Resize(newsize);
2957 return true;
2958 }
2959
2960 std::string ArrayManager::asString(std::function<char const*(int32_t)> formatter, const size_t& limit) const
2961 {
2962 if(_invalid) return "{ INVALID ARRAY }";
2963 std::ostringstream oss;
2964 oss << "{ ";
2965 size_t s = size();
2966 bool overflow = limit < s;
2967 if(overflow)
2968 s = limit;
2969
2970 for(auto q = 0; q < s; ++q)
2971 {
2972 oss << formatter(get(q));
2973 if (q + 1 < s)
2974 oss << ", ";
2975 }
2976 if (overflow)
2977 oss << ", ...";
2978 oss << " }";
2979 return oss.str();
2980 }
2981
2982 // Called to deallocate arrays when a script stops running
2983 24490 void deallocateArray(const int32_t ptrval)
2984 {
2985
1/2
✓ Branch 0 taken 24490 times.
✗ Branch 1 not taken.
24490 if(ptrval == 0) return;
2986
2/4
✓ Branch 0 taken 24490 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24490 times.
24490 if(ptrval==0 || ptrval >= NUM_ZSCRIPT_ARRAYS)
2987 Z_scripterrlog("Script tried to deallocate memory at invalid address %ld\n", ptrval);
2988
1/2
✓ Branch 0 taken 24490 times.
✗ Branch 1 not taken.
24490 else if(ptrval<0)
2989 Z_scripterrlog("Script tried to deallocate memory at object-based address %ld\n", ptrval);
2990 else
2991 {
2992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24490 times.
24490 if(arrayOwner[ptrval].specOwned) return; //ignore this deallocation
2993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24490 times.
24490 if(arrayOwner[ptrval].specCleared) return;
2994 24490 arrayOwner[ptrval].clear();
2995
2996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24490 times.
24490 if(localRAM[ptrval].Size() == 0)
2997 Z_scripterrlog("Script tried to deallocate memory that was not allocated at address %ld\n", ptrval);
2998 else
2999 {
3000 24490 word size = localRAM[ptrval].Size();
3001 24490 localRAM[ptrval].Clear();
3002
3003 // If this happens once per frame, it can drown out every other message. -L
3004 //Z_eventlog("Deallocated local array with address %ld, size %d\n", ptrval, size);
3005 24490 size = size;
3006 }
3007 }
3008 24490 }
3009
3010 3593713 void FFScript::deallocateAllArrays(ScriptType scriptType, const int32_t UID, bool requireAlways)
3011 {
3012
2/2
✓ Branch 0 taken 894834537 times.
✓ Branch 1 taken 3593713 times.
898428250 for(int32_t q = MIN_USER_BITMAPS; q < MAX_USER_BITMAPS; ++q)
3013 {
3014 894834537 scb.script_created_bitmaps[q].own_clear(scriptType, UID);
3015 894834537 }
3016
2/2
✓ Branch 0 taken 919990528 times.
✓ Branch 1 taken 3593713 times.
923584241 for(int32_t q = 0; q < MAX_USER_RNGS; ++q)
3017 {
3018 919990528 script_rngs[q].own_clear(scriptType, UID);
3019 919990528 }
3020
2/2
✓ Branch 0 taken 919990528 times.
✓ Branch 1 taken 3593713 times.
923584241 for (int32_t q = 0; q < MAX_USER_PALDATAS; ++q)
3021 {
3022 919990528 script_paldatas[q].own_clear(scriptType, UID);
3023 919990528 }
3024
2/2
✓ Branch 0 taken 919990528 times.
✓ Branch 1 taken 3593713 times.
923584241 for(int32_t q = 0; q < MAX_USER_FILES; ++q)
3025 {
3026 919990528 script_files[q].own_clear(scriptType, UID);
3027 919990528 }
3028
2/2
✓ Branch 0 taken 919990528 times.
✓ Branch 1 taken 3593713 times.
923584241 for(int32_t q = 0; q < MAX_USER_DIRS; ++q)
3029 {
3030 919990528 script_dirs[q].own_clear(scriptType, UID);
3031 919990528 }
3032
2/2
✓ Branch 0 taken 919990528 times.
✓ Branch 1 taken 3593713 times.
923584241 for(int32_t q = 0; q < MAX_USER_STACKS; ++q)
3033 {
3034 919990528 script_stacks[q].own_clear(scriptType, UID);
3035 919990528 }
3036
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3593713 times.
3593713 for(int32_t q = 0; q < max_valid_object; ++q)
3037 {
3038 script_objects[q].own_clear(scriptType, UID);
3039 }
3040
4/4
✓ Branch 0 taken 1508609 times.
✓ Branch 1 taken 2085104 times.
✓ Branch 2 taken 234219 times.
✓ Branch 3 taken 1274390 times.
3593713 if(requireAlways && !get_qr(qr_ALWAYS_DEALLOCATE_ARRAYS))
3041 {
3042 //Keep 2.50.2 behavior if QR unchecked.
3043
2/2
✓ Branch 0 taken 1255741 times.
✓ Branch 1 taken 18649 times.
1274390 switch(scriptType)
3044 {
3045 case ScriptType::FFC:
3046 case ScriptType::Item:
3047 case ScriptType::Global:
3048 18649 return;
3049 }
3050 1255741 }
3051 //Z_eventlog("Attempting array deallocation from %s UID %d\n", script_types[scriptType], UID);
3052
2/2
✓ Branch 0 taken 3575064 times.
✓ Branch 1 taken 14639887080 times.
14643462144 for(int32_t i = 1; i < NUM_ZSCRIPT_ARRAYS; i++)
3053 {
3054
4/4
✓ Branch 0 taken 169215 times.
✓ Branch 1 taken 14639717865 times.
✓ Branch 2 taken 147695 times.
✓ Branch 3 taken 21520 times.
14639887080 if(arrayOwner[i].scriptType == scriptType && arrayOwner[i].ownerUID==UID)
3055 {
3056 21520 arrayOwner[i].specOwned = false;
3057 21520 deallocateArray(i);
3058 //Z_eventlog("Deallocated array %d from %s UID %d\n", i, script_types[scriptType], UID);
3059 21520 }
3060 14639887080 }
3061 3593713 }
3062
3063 391 void FFScript::deallocateAllArrays()
3064 {
3065
2/2
✓ Branch 0 taken 97359 times.
✓ Branch 1 taken 391 times.
97750 for(int32_t q = MIN_USER_BITMAPS; q < MAX_USER_BITMAPS; ++q)
3066 {
3067 97359 scb.script_created_bitmaps[q].own_clear_any();
3068 97359 }
3069
2/2
✓ Branch 0 taken 100096 times.
✓ Branch 1 taken 391 times.
100487 for(int32_t q = 0; q < MAX_USER_RNGS; ++q)
3070 {
3071 100096 script_rngs[q].own_clear_any();
3072 100096 }
3073
2/2
✓ Branch 0 taken 100096 times.
✓ Branch 1 taken 391 times.
100487 for (int32_t q = 0; q < MAX_USER_PALDATAS; ++q)
3074 {
3075 100096 script_paldatas[q].own_clear_any();
3076 100096 }
3077
2/2
✓ Branch 0 taken 100096 times.
✓ Branch 1 taken 391 times.
100487 for(int32_t q = 0; q < MAX_USER_FILES; ++q)
3078 {
3079 100096 script_files[q].own_clear_any();
3080 100096 }
3081
2/2
✓ Branch 0 taken 100096 times.
✓ Branch 1 taken 391 times.
100487 for(int32_t q = 0; q < MAX_USER_DIRS; ++q)
3082 {
3083 100096 script_dirs[q].own_clear_any();
3084 100096 }
3085
2/2
✓ Branch 0 taken 100096 times.
✓ Branch 1 taken 391 times.
100487 for(int32_t q = 0; q < MAX_USER_STACKS; ++q)
3086 {
3087 100096 script_stacks[q].own_clear_any();
3088 100096 }
3089
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 391 times.
391 for(int32_t q = 0; q < max_valid_object; ++q)
3090 {
3091 script_objects[q].own_clear_any();
3092 }
3093 //No QR check here- always deallocate on quest exit.
3094
2/2
✓ Branch 0 taken 1601145 times.
✓ Branch 1 taken 391 times.
1601536 for(int32_t i = 1; i < NUM_ZSCRIPT_ARRAYS; i++)
3095 {
3096
2/2
✓ Branch 0 taken 1598175 times.
✓ Branch 1 taken 2970 times.
1601145 if(localRAM[i].Size() > 0)
3097 {
3098 2970 arrayOwner[i].specOwned = false;
3099 //Z_eventlog("Deallocated array %d from %s UID %d\n", i, script_types[arrayOwner[i].scriptType], arrayOwner[i].ownerUID);
3100 2970 deallocateArray(i);
3101 2970 }
3102 1601145 }
3103 391 }
3104
3105 409929 item *checkItem(int32_t iid)
3106 {
3107 409929 item *s = (item *)items.getByUID(iid);
3108
3109
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 409929 times.
409929 if(s == NULL)
3110 {
3111 Z_eventlog("Script attempted to reference a nonexistent item!\n");
3112 Z_eventlog("You were trying to reference an item with UID = %ld; Items on screen are UIDs ", iid);
3113
3114 for(int32_t i=0; i<items.Count(); i++)
3115 {
3116 Z_eventlog("%ld ", items.spr(i)->getUID());
3117 }
3118
3119 Z_eventlog("\n");
3120 return NULL;
3121 }
3122
3123 409929 return s;
3124 409929 }
3125
3126 10097911 weapon *checkLWpn(int32_t eid, const char *what)
3127 {
3128 10097911 weapon *s = (weapon *)Lwpns.getByUID(eid);
3129
2/2
✓ Branch 0 taken 9981466 times.
✓ Branch 1 taken 116445 times.
10097911 if(s == NULL) //check lifted weapon
3130 {
3131 116445 weapon* lw = Hero.lift_wpn;
3132
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 116445 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
116445 if(lw && lw->getUID() == eid)
3133 s = lw;
3134 116445 }
3135
2/2
✓ Branch 0 taken 9981466 times.
✓ Branch 1 taken 116445 times.
10097911 if(s == NULL)
3136 {
3137
3138 116445 Z_eventlog("Script attempted to reference a nonexistent LWeapon!\n");
3139 116445 Z_eventlog("You were trying to reference the %s of an LWeapon with UID = %ld; LWeapons on screen are UIDs ", what, eid);
3140
3141
2/2
✓ Branch 0 taken 71278 times.
✓ Branch 1 taken 116445 times.
187723 for(int32_t i=0; i<Lwpns.Count(); i++)
3142 {
3143 71278 Z_eventlog("%ld ", Lwpns.spr(i)->getUID());
3144 71278 }
3145
3146 116445 Z_eventlog("\n");
3147 116445 return NULL;
3148 }
3149
3150 9981466 return s;
3151 10097911 }
3152
3153 23422487 weapon *checkEWpn(int32_t eid, const char *what)
3154 {
3155 23422487 weapon *s = (weapon *)Ewpns.getByUID(eid);
3156
3157
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 23422483 times.
23422487 if(s == NULL)
3158 {
3159
3160 4 Z_eventlog("Script attempted to reference a nonexistent EWeapon!\n");
3161 4 Z_eventlog("You were trying to reference the %s of an EWeapon with UID = %ld; EWeapons on screen are UIDs ", what, eid);
3162
3163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 for(int32_t i=0; i<Ewpns.Count(); i++)
3164 {
3165 Z_eventlog("%ld ", Ewpns.spr(i)->getUID());
3166 }
3167
3168 4 Z_eventlog("\n");
3169 4 return NULL;
3170 }
3171
3172 23422483 return s;
3173 23422487 }
3174
3175 286 user_file *checkFile(int32_t ref, const char *what, bool req_file = false, bool skipError = false)
3176 {
3177
3/4
✓ Branch 0 taken 284 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 284 times.
286 if(ref > 0 && ref <= MAX_USER_FILES)
3178 {
3179 284 user_file* f = &script_files[ref-1];
3180
1/2
✓ Branch 0 taken 284 times.
✗ Branch 1 not taken.
284 if(f->reserved)
3181 {
3182
3/4
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 280 times.
284 if(req_file && !f->file)
3183 {
3184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280 times.
280 if(skipError) return NULL;
3185 280 Z_scripterrlog("Script attempted to reference an invalid file!\n");
3186 280 Z_scripterrlog("File with UID = %ld does not have an open file connection!\n",ref);
3187 280 Z_scripterrlog("Use '->Open()' or '->Create()' to hook to a system file.\n");
3188 280 return NULL;
3189 }
3190 4 return f;
3191 }
3192 }
3193
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(skipError) return NULL;
3194 Z_scripterrlog("Script attempted to reference a nonexistent File!\n");
3195 if(what)
3196 Z_scripterrlog("You were trying to reference the '%s' of a File with UID = %ld\n", what, ref);
3197 else
3198 Z_scripterrlog("You were trying to reference with UID = %ld\n", ref);
3199 return NULL;
3200 286 }
3201
3202 user_object *checkObject(int32_t ref, bool skipError = false)
3203 {
3204 if(ref > 0 && ref <= MAX_USER_FILES)
3205 {
3206 user_object* obj = &script_objects[ref-1];
3207 if(obj->reserved)
3208 {
3209 return obj;
3210 }
3211 }
3212 if(skipError) return NULL;
3213 Z_scripterrlog("Script attempted to reference a nonexistent object!\n");
3214 Z_scripterrlog("You were trying to reference an object with UID = %ld\n", ref);
3215 return NULL;
3216 }
3217
3218 132 user_genscript *checkGenericScr(int32_t ref, const char *what)
3219 {
3220
2/4
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 132 times.
132 if(ref < 1 || ref >= NUMSCRIPTSGENERIC)
3221 {
3222 Z_scripterrlog("Invalid gendata pointer access (%ld) for '->%s'\n", ref, what);
3223 return NULL;
3224 }
3225 132 return &user_scripts[ref];
3226 132 }
3227 extern portal mirror_portal;
3228 portal *checkPortal(int32_t ref, const char *what, bool skiperr = false)
3229 {
3230 if(ref == -1)
3231 return &mirror_portal;
3232 portal* p = (portal*)portals.getByUID(ref);
3233 if(!p)
3234 {
3235 if(!skiperr)
3236 Z_scripterrlog("Invalid portal pointer access (%ld) for '->%s'\n", ref, what);
3237 return nullptr;
3238 }
3239 return p;
3240 }
3241
3242 savedportal *checkSavedPortal(int32_t ref, const char* what, bool skiperr = false)
3243 {
3244 savedportal* sp = game->getSavedPortal(ref);
3245 if(!sp)
3246 {
3247 if(!skiperr)
3248 Z_scripterrlog("Invalid savedportal pointer access (%ld) for '->%s'\n", ref, what);
3249 return nullptr;
3250 }
3251 return sp;
3252 }
3253 int32_t getPortalFromSaved(savedportal* p)
3254 {
3255 if(p == &(game->saved_mirror_portal))
3256 return -1;
3257 portal* prtl = nullptr;
3258 portals.forEach([&](sprite& spr)
3259 {
3260 portal* tmp = (portal*)&spr;
3261 if(p->getUID() == tmp->saved_data)
3262 {
3263 prtl = tmp;
3264 return true;
3265 }
3266 return false;
3267 });
3268 return prtl ? prtl->getUID() : 0;
3269 }
3270
3271 user_dir *checkDir(int32_t ref, const char *what, bool skipError = false)
3272 {
3273 if(ref > 0 && ref <= MAX_USER_DIRS)
3274 {
3275 user_dir* dr = &script_dirs[ref-1];
3276 if(dr->reserved)
3277 {
3278 return dr;
3279 }
3280 }
3281 if(skipError) return NULL;
3282 Z_scripterrlog("Script attempted to reference a nonexistent Directory!\n");
3283 if(what)
3284 Z_scripterrlog("You were trying to reference the '%s' of a Directory with UID = %ld\n", what, ref);
3285 else
3286 Z_scripterrlog("You were trying to reference with UID = %ld\n", ref);
3287 return NULL;
3288 }
3289
3290 user_stack *checkStack(int32_t ref, const char *what, bool skipError = false)
3291 {
3292 if(ref > 0 && ref <= USERSTACK_MAX_SIZE)
3293 {
3294 user_stack* st = &script_stacks[ref-1];
3295 if(st->reserved)
3296 {
3297 return st;
3298 }
3299 }
3300 if(skipError) return NULL;
3301 Z_scripterrlog("Script attempted to reference a nonexistent Stack!\n");
3302 if(what)
3303 Z_scripterrlog("You were trying to reference the '%s' of a Stack with UID = %ld\n", what, ref);
3304 else
3305 Z_scripterrlog("You were trying to reference with UID = %ld\n", ref);
3306 return NULL;
3307 }
3308
3309 303330 user_rng *checkRNG(int32_t ref, const char *what, bool skipError = false)
3310 {
3311
3/4
✓ Branch 0 taken 1523 times.
✓ Branch 1 taken 301807 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1523 times.
303330 if(ref > 0 && ref <= MAX_USER_RNGS)
3312 {
3313 1523 user_rng* rng = &script_rngs[ref-1];
3314
1/2
✓ Branch 0 taken 1523 times.
✗ Branch 1 not taken.
1523 if(rng->reserved)
3315 {
3316 1523 return rng;
3317 }
3318 }
3319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 301807 times.
301807 else if(!ref) //A null RNG pointer is special-case, access engine rng.
3320 {
3321 301807 return &nulrng;
3322 }
3323 if(skipError) return NULL;
3324 Z_scripterrlog("Script attempted to reference a nonexistent RNG!\n");
3325 if(what)
3326 Z_scripterrlog("You were trying to reference the '%s' of a RNG with UID = %ld\n", what, ref);
3327 else
3328 Z_scripterrlog("You were trying to reference with UID = %ld\n", ref);
3329 return NULL;
3330 303330 }
3331
3332 user_paldata* checkPalData(int32_t ref, const char* what, bool skipError = false)
3333 {
3334 if (ref > 0 && ref <= MAX_USER_PALDATAS)
3335 {
3336 user_paldata* pd = &script_paldatas[ref - 1];
3337 if (pd->reserved)
3338 {
3339 return pd;
3340 }
3341 }
3342 if (skipError) return NULL;
3343 Z_scripterrlog("Script attempted to reference a nonexistent paldata!\n");
3344 if(what)
3345 Z_scripterrlog("You were trying to reference the '%s' of a paldata with UID = %ld\n", what, ref);
3346 else
3347 Z_scripterrlog("You were trying to reference with UID = %ld\n", ref);
3348 return NULL;
3349 }
3350
3351 bottletype *checkBottleData(int32_t ref, const char *what, bool skipError = false)
3352 {
3353 if(ref > 0 && ref <= 64)
3354 {
3355 return &QMisc.bottle_types[ref-1];
3356 }
3357 if(skipError) return NULL;
3358 Z_scripterrlog("Script attempted to reference a nonexistent BottleData!\n");
3359 Z_scripterrlog("You were trying to reference the '%s' of a BottleData with UID = %ld\n", what, ref);
3360 return NULL;
3361 }
3362
3363 bottleshoptype *checkBottleShopData(int32_t ref, const char *what, bool skipError = false)
3364 {
3365 if(ref > 0 && ref <= 256)
3366 {
3367 return &QMisc.bottle_shop_types[ref-1];
3368 }
3369 if(skipError) return NULL;
3370 Z_scripterrlog("Script attempted to reference a nonexistent BottleShopData!\n");
3371 Z_scripterrlog("You were trying to reference the '%s' of a BottleShopData with UID = %ld\n", what, ref);
3372 return NULL;
3373 }
3374
3375 631599 user_bitmap *checkBitmap(int32_t ref, const char *what, bool req_valid = false, bool skipError = false)
3376 {
3377 631599 int32_t ind = ref - 10;
3378
2/4
✓ Branch 0 taken 631599 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 631599 times.
631599 if(ind >= firstUserGeneratedBitmap && ind < MAX_USER_BITMAPS)
3379 {
3380 631599 user_bitmap* b = &(scb.script_created_bitmaps[ind]);
3381
1/2
✓ Branch 0 taken 631599 times.
✗ Branch 1 not taken.
631599 if(b->reserved())
3382 {
3383
3/4
✓ Branch 0 taken 604925 times.
✓ Branch 1 taken 26674 times.
✓ Branch 2 taken 604925 times.
✗ Branch 3 not taken.
631599 if(req_valid && !b->u_bmp)
3384 {
3385 if(skipError) return NULL;
3386 Z_scripterrlog("Script attempted to reference an invalid bitmap!\n");
3387 Z_scripterrlog("Bitmap with UID = %ld does not have a valid memory bitmap!\n",ref);
3388 Z_scripterrlog("Use '->Create()' to create a memory bitmap.\n");
3389 return NULL;
3390 }
3391 631599 return b;
3392 }
3393 }
3394 else
3395 {
3396 switch(ind)
3397 {
3398 case rtSCREEN:
3399 case rtBMP0:
3400 case rtBMP1:
3401 case rtBMP2:
3402 case rtBMP3:
3403 case rtBMP4:
3404 case rtBMP5:
3405 case rtBMP6:
3406 zprint2("Internal error: 'checkBitmap()' recieved ref pointing to system bitmap!\n");
3407 zprint2("Please report this as a bug!\n");
3408 break;
3409 }
3410 }
3411 if(skipError) return NULL;
3412 Z_scripterrlog("Script attempted to reference a nonexistent bitmap!\n");
3413 if(what)
3414 Z_scripterrlog("You were trying to reference the '%s' of a bitmap with UID = %ld\n", what, ref);
3415 else
3416 Z_scripterrlog("You were trying to reference with UID = %ld\n", ref);
3417 return NULL;
3418 631599 }
3419
3420 int32_t get_screen_d(int32_t index1, int32_t index2)
3421 {
3422 if(index2 < 0 || index2 > 7)
3423 {
3424 Z_scripterrlog("You were trying to reference an out-of-bounds array index for a screen's D[] array (%ld); valid indices are from 0 to 7.\n", index1);
3425 return 0;
3426 }
3427
3428 return game->screen_d[index1][index2];
3429 }
3430
3431 void set_screen_d(int32_t index1, int32_t index2, int32_t val)
3432 {
3433 if(index2 < 0 || index2 > 7)
3434 {
3435 Z_scripterrlog("You were trying to reference an out-of-bounds array index for a screen's D[] array (%ld); valid indices are from 0 to 7.\n", index1);
3436 return;
3437 }
3438
3439 game->screen_d[index1][index2] = val;
3440 }
3441
3442 // If scr is currently being used as a layer, return that layer no.
3443 39845144 int32_t whichlayer(int32_t scr)
3444 {
3445
2/2
✓ Branch 0 taken 198687540 times.
✓ Branch 1 taken 28204008 times.
226891548 for(int32_t i = 0; i < 6; i++)
3446 {
3447
2/2
✓ Branch 0 taken 11641136 times.
✓ Branch 1 taken 187046404 times.
198687540 if(scr == (tmpscr->layermap[i] - 1) * MAPSCRS + tmpscr->layerscreen[i])
3448 11641136 return i;
3449 187046404 }
3450
3451 28204008 return -1;
3452 39845144 }
3453
3454 sprite *s;
3455
3456 int32_t item_flag(int32_t flag)
3457 {
3458 if(unsigned(ri->idata) >= MAXITEMS)
3459 {
3460 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
3461 return 0;
3462 }
3463 return (itemsbuf[ri->idata].flags & flag) ? 10000 : 0;
3464 }
3465 void item_flag(int32_t flag, bool val)
3466 {
3467 if(unsigned(ri->idata) >= MAXITEMS)
3468 {
3469 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
3470 return;
3471 }
3472 SETFLAG(itemsbuf[ri->idata].flags, flag, val);
3473 }
3474
3475 //Forward decl
3476 int32_t do_msgheight(int32_t msg, char const* str);
3477 int32_t do_msgwidth(int32_t msg, char const* str);
3478 //
3479
3480 int32_t earlyretval = -1;
3481 2760569860 int32_t get_register(const int32_t arg)
3482 {
3483 2760569860 int32_t ret = 0;
3484
3485 //Macros
3486
3487 #define GET_SPRITEDATA_VAR_INT(member, str) \
3488 { \
3489 if(unsigned(ri->spritesref) > (MAXWPNS-1) ) \
3490 { \
3491 ret = -10000; \
3492 Z_scripterrlog("Invalid Sprite ID passed to spritedata->%s: %d\n", str, (ri->spritesref*10000));\
3493 } \
3494 else \
3495 ret = (wpnsbuf[ri->spritesref].member * 10000); \
3496 }
3497
3498
326/1267
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4436597 times.
✓ Branch 4 taken 468471068 times.
✓ Branch 5 taken 1183551 times.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 8343962 times.
✓ Branch 8 taken 7892556 times.
✓ Branch 9 taken 35 times.
✓ Branch 10 taken 35 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 35 times.
✓ Branch 13 taken 35 times.
✓ Branch 14 taken 2177905 times.
✓ Branch 15 taken 103 times.
✓ Branch 16 taken 98 times.
✓ Branch 17 taken 2593791 times.
✓ Branch 18 taken 2594062 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 1282 times.
✓ Branch 21 taken 641181 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 756380 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 15442165 times.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 2112268 times.
✓ Branch 29 taken 655865 times.
✓ Branch 30 taken 552027 times.
✓ Branch 31 taken 44790481 times.
✓ Branch 32 taken 17 times.
✓ Branch 33 taken 19585851 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 5424 times.
✓ Branch 36 taken 801723 times.
✓ Branch 37 taken 557644 times.
✓ Branch 38 taken 623338 times.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✓ Branch 42 taken 280566 times.
✓ Branch 43 taken 481556 times.
✗ Branch 44 not taken.
✓ Branch 45 taken 6213788 times.
✗ Branch 46 not taken.
✓ Branch 47 taken 206522 times.
✓ Branch 48 taken 206522 times.
✗ Branch 49 not taken.
✗ Branch 50 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✓ Branch 53 taken 206547 times.
✓ Branch 54 taken 206547 times.
✓ Branch 55 taken 173466 times.
✗ Branch 56 not taken.
✗ Branch 57 not taken.
✓ Branch 58 taken 4636 times.
✗ Branch 59 not taken.
✗ Branch 60 not taken.
✗ Branch 61 not taken.
✗ Branch 62 not taken.
✗ Branch 63 not taken.
✗ Branch 64 not taken.
✗ Branch 65 not taken.
✗ Branch 66 not taken.
✗ Branch 67 not taken.
✓ Branch 68 taken 2 times.
✗ Branch 69 not taken.
✗ Branch 70 not taken.
✓ Branch 71 taken 15348 times.
✓ Branch 72 taken 15551 times.
✓ Branch 73 taken 12319 times.
✓ Branch 74 taken 13864 times.
✗ Branch 75 not taken.
✗ Branch 76 not taken.
✗ Branch 77 not taken.
✗ Branch 78 not taken.
✗ Branch 79 not taken.
✗ Branch 80 not taken.
✗ Branch 81 not taken.
✓ Branch 82 taken 88721 times.
✗ Branch 83 not taken.
✗ Branch 84 not taken.
✗ Branch 85 not taken.
✗ Branch 86 not taken.
✗ Branch 87 not taken.
✗ Branch 88 not taken.
✗ Branch 89 not taken.
✗ Branch 90 not taken.
✗ Branch 91 not taken.
✗ Branch 92 not taken.
✗ Branch 93 not taken.
✗ Branch 94 not taken.
✗ Branch 95 not taken.
✗ Branch 96 not taken.
✗ Branch 97 not taken.
✗ Branch 98 not taken.
✗ Branch 99 not taken.
✗ Branch 100 not taken.
✗ Branch 101 not taken.
✗ Branch 102 not taken.
✓ Branch 103 taken 92884 times.
✓ Branch 104 taken 4123 times.
✓ Branch 105 taken 1334115 times.
✓ Branch 106 taken 847431 times.
✓ Branch 107 taken 1327379 times.
✓ Branch 108 taken 1369597 times.
✓ Branch 109 taken 5693944 times.
✓ Branch 110 taken 5182994 times.
✓ Branch 111 taken 3135646 times.
✓ Branch 112 taken 3131387 times.
✓ Branch 113 taken 119289 times.
✓ Branch 114 taken 119580 times.
✓ Branch 115 taken 23391 times.
✓ Branch 116 taken 23391 times.
✗ Branch 117 not taken.
✗ Branch 118 not taken.
✗ Branch 119 not taken.
✗ Branch 120 not taken.
✓ Branch 121 taken 766680 times.
✗ Branch 122 not taken.
✓ Branch 123 taken 1041016 times.
✓ Branch 124 taken 728101 times.
✓ Branch 125 taken 276546 times.
✓ Branch 126 taken 775420 times.
✓ Branch 127 taken 715403 times.
✓ Branch 128 taken 556980 times.
✓ Branch 129 taken 514803 times.
✓ Branch 130 taken 1875584 times.
✓ Branch 131 taken 1726419 times.
✓ Branch 132 taken 1861217 times.
✓ Branch 133 taken 1691656 times.
✓ Branch 134 taken 873882 times.
✓ Branch 135 taken 873847 times.
✓ Branch 136 taken 541201 times.
✓ Branch 137 taken 541201 times.
✗ Branch 138 not taken.
✗ Branch 139 not taken.
✗ Branch 140 not taken.
✗ Branch 141 not taken.
✗ Branch 142 not taken.
✗ Branch 143 not taken.
✗ Branch 144 not taken.
✗ Branch 145 not taken.
✗ Branch 146 not taken.
✓ Branch 147 taken 1121 times.
✓ Branch 148 taken 6213 times.
✗ Branch 149 not taken.
✗ Branch 150 not taken.
✗ Branch 151 not taken.
✗ Branch 152 not taken.
✗ Branch 153 not taken.
✓ Branch 154 taken 5848 times.
✗ Branch 155 not taken.
✓ Branch 156 taken 24 times.
✗ Branch 157 not taken.
✗ Branch 158 not taken.
✗ Branch 159 not taken.
✗ Branch 160 not taken.
✓ Branch 161 taken 4206 times.
✓ Branch 162 taken 5084 times.
✓ Branch 163 taken 114 times.
✗ Branch 164 not taken.
✗ Branch 165 not taken.
✗ Branch 166 not taken.
✓ Branch 167 taken 117090 times.
✓ Branch 168 taken 7933 times.
✗ Branch 169 not taken.
✗ Branch 170 not taken.
✗ Branch 171 not taken.
✗ Branch 172 not taken.
✗ Branch 173 not taken.
✓ Branch 174 taken 18 times.
✓ Branch 175 taken 7933 times.
✗ Branch 176 not taken.
✗ Branch 177 not taken.
✗ Branch 178 not taken.
✗ Branch 179 not taken.
✗ Branch 180 not taken.
✗ Branch 181 not taken.
✗ Branch 182 not taken.
✗ Branch 183 not taken.
✓ Branch 184 taken 2552 times.
✓ Branch 185 taken 2552 times.
✓ Branch 186 taken 6 times.
✓ Branch 187 taken 334 times.
✗ Branch 188 not taken.
✗ Branch 189 not taken.
✗ Branch 190 not taken.
✓ Branch 191 taken 2552 times.
✓ Branch 192 taken 2552 times.
✓ Branch 193 taken 2542 times.
✓ Branch 194 taken 1300 times.
✓ Branch 195 taken 1300 times.
✓ Branch 196 taken 685905 times.
✗ Branch 197 not taken.
✗ Branch 198 not taken.
✓ Branch 199 taken 19906 times.
✓ Branch 200 taken 108294 times.
✗ Branch 201 not taken.
✗ Branch 202 not taken.
✗ Branch 203 not taken.
✗ Branch 204 not taken.
✗ Branch 205 not taken.
✗ Branch 206 not taken.
✗ Branch 207 not taken.
✗ Branch 208 not taken.
✗ Branch 209 not taken.
✗ Branch 210 not taken.
✗ Branch 211 not taken.
✗ Branch 212 not taken.
✗ Branch 213 not taken.
✗ Branch 214 not taken.
✗ Branch 215 not taken.
✗ Branch 216 not taken.
✗ Branch 217 not taken.
✗ Branch 218 not taken.
✗ Branch 219 not taken.
✗ Branch 220 not taken.
✗ Branch 221 not taken.
✗ Branch 222 not taken.
✗ Branch 223 not taken.
✗ Branch 224 not taken.
✗ Branch 225 not taken.
✗ Branch 226 not taken.
✗ Branch 227 not taken.
✗ Branch 228 not taken.
✗ Branch 229 not taken.
✗ Branch 230 not taken.
✗ Branch 231 not taken.
✗ Branch 232 not taken.
✗ Branch 233 not taken.
✗ Branch 234 not taken.
✗ Branch 235 not taken.
✗ Branch 236 not taken.
✗ Branch 237 not taken.
✗ Branch 238 not taken.
✗ Branch 239 not taken.
✗ Branch 240 not taken.
✗ Branch 241 not taken.
✗ Branch 242 not taken.
✗ Branch 243 not taken.
✓ Branch 244 taken 713905 times.
✗ Branch 245 not taken.
✓ Branch 246 taken 709431 times.
✓ Branch 247 taken 55748 times.
✗ Branch 248 not taken.
✗ Branch 249 not taken.
✓ Branch 250 taken 67667 times.
✗ Branch 251 not taken.
✓ Branch 252 taken 1329 times.
✓ Branch 253 taken 2 times.
✗ Branch 254 not taken.
✗ Branch 255 not taken.
✗ Branch 256 not taken.
✗ Branch 257 not taken.
✗ Branch 258 not taken.
✗ Branch 259 not taken.
✗ Branch 260 not taken.
✓ Branch 261 taken 85830 times.
✓ Branch 262 taken 1122 times.
✓ Branch 263 taken 3785245 times.
✓ Branch 264 taken 49772 times.
✗ Branch 265 not taken.
✗ Branch 266 not taken.
✓ Branch 267 taken 49794 times.
✗ Branch 268 not taken.
✓ Branch 269 taken 3289 times.
✗ Branch 270 not taken.
✓ Branch 271 taken 3289 times.
✗ Branch 272 not taken.
✗ Branch 273 not taken.
✓ Branch 274 taken 1094820 times.
✗ Branch 275 not taken.
✓ Branch 276 taken 830567 times.
✗ Branch 277 not taken.
✓ Branch 278 taken 135142 times.
✓ Branch 279 taken 132394 times.
✗ Branch 280 not taken.
✗ Branch 281 not taken.
✗ Branch 282 not taken.
✗ Branch 283 not taken.
✗ Branch 284 not taken.
✗ Branch 285 not taken.
✓ Branch 286 taken 133136 times.
✓ Branch 287 taken 135091 times.
✓ Branch 288 taken 27874 times.
✓ Branch 289 taken 25249 times.
✓ Branch 290 taken 25249 times.
✓ Branch 291 taken 1553638 times.
✓ Branch 292 taken 4320 times.
✗ Branch 293 not taken.
✗ Branch 294 not taken.
✗ Branch 295 not taken.
✗ Branch 296 not taken.
✓ Branch 297 taken 179 times.
✗ Branch 298 not taken.
✓ Branch 299 taken 180 times.
✗ Branch 300 not taken.
✗ Branch 301 not taken.
✗ Branch 302 not taken.
✗ Branch 303 not taken.
✗ Branch 304 not taken.
✗ Branch 305 not taken.
✗ Branch 306 not taken.
✗ Branch 307 not taken.
✗ Branch 308 not taken.
✗ Branch 309 not taken.
✗ Branch 310 not taken.
✗ Branch 311 not taken.
✗ Branch 312 not taken.
✗ Branch 313 not taken.
✗ Branch 314 not taken.
✗ Branch 315 not taken.
✗ Branch 316 not taken.
✗ Branch 317 not taken.
✗ Branch 318 not taken.
✗ Branch 319 not taken.
✗ Branch 320 not taken.
✗ Branch 321 not taken.
✗ Branch 322 not taken.
✓ Branch 323 taken 1266708 times.
✓ Branch 324 taken 63485 times.
✗ Branch 325 not taken.
✗ Branch 326 not taken.
✓ Branch 327 taken 22679 times.
✗ Branch 328 not taken.
✗ Branch 329 not taken.
✓ Branch 330 taken 362690 times.
✓ Branch 331 taken 373525 times.
✗ Branch 332 not taken.
✗ Branch 333 not taken.
✗ Branch 334 not taken.
✓ Branch 335 taken 68688 times.
✗ Branch 336 not taken.
✗ Branch 337 not taken.
✓ Branch 338 taken 46359 times.
✓ Branch 339 taken 90188 times.
✓ Branch 340 taken 154 times.
✓ Branch 341 taken 2150394 times.
✓ Branch 342 taken 106032 times.
✗ Branch 343 not taken.
✗ Branch 344 not taken.
✓ Branch 345 taken 24909 times.
✗ Branch 346 not taken.
✓ Branch 347 taken 70 times.
✗ Branch 348 not taken.
✓ Branch 349 taken 70 times.
✗ Branch 350 not taken.
✗ Branch 351 not taken.
✓ Branch 352 taken 1911385 times.
✗ Branch 353 not taken.
✓ Branch 354 taken 2925 times.
✗ Branch 355 not taken.
✓ Branch 356 taken 65540 times.
✓ Branch 357 taken 65540 times.
✓ Branch 358 taken 8 times.
✓ Branch 359 taken 96 times.
✗ Branch 360 not taken.
✗ Branch 361 not taken.
✗ Branch 362 not taken.
✗ Branch 363 not taken.
✓ Branch 364 taken 62523 times.
✓ Branch 365 taken 62523 times.
✓ Branch 366 taken 12470 times.
✓ Branch 367 taken 24497 times.
✓ Branch 368 taken 24497 times.
✓ Branch 369 taken 13780500 times.
✗ Branch 370 not taken.
✗ Branch 371 not taken.
✗ Branch 372 not taken.
✗ Branch 373 not taken.
✗ Branch 374 not taken.
✗ Branch 375 not taken.
✓ Branch 376 taken 16680 times.
✗ Branch 377 not taken.
✗ Branch 378 not taken.
✗ Branch 379 not taken.
✗ Branch 380 not taken.
✗ Branch 381 not taken.
✗ Branch 382 not taken.
✗ Branch 383 not taken.
✗ Branch 384 not taken.
✗ Branch 385 not taken.
✗ Branch 386 not taken.
✗ Branch 387 not taken.
✗ Branch 388 not taken.
✗ Branch 389 not taken.
✗ Branch 390 not taken.
✗ Branch 391 not taken.
✗ Branch 392 not taken.
✗ Branch 393 not taken.
✗ Branch 394 not taken.
✗ Branch 395 not taken.
✗ Branch 396 not taken.
✗ Branch 397 not taken.
✗ Branch 398 not taken.
✗ Branch 399 not taken.
✗ Branch 400 not taken.
✗ Branch 401 not taken.
✗ Branch 402 not taken.
✗ Branch 403 not taken.
✗ Branch 404 not taken.
✗ Branch 405 not taken.
✗ Branch 406 not taken.
✗ Branch 407 not taken.
✗ Branch 408 not taken.
✗ Branch 409 not taken.
✗ Branch 410 not taken.
✗ Branch 411 not taken.
✗ Branch 412 not taken.
✗ Branch 413 not taken.
✗ Branch 414 not taken.
✓ Branch 415 taken 17 times.
✓ Branch 416 taken 26 times.
✓ Branch 417 taken 678 times.
✓ Branch 418 taken 972 times.
✓ Branch 419 taken 14 times.
✓ Branch 420 taken 471 times.
✓ Branch 421 taken 4013519 times.
✓ Branch 422 taken 1586472 times.
✓ Branch 423 taken 15 times.
✓ Branch 424 taken 16 times.
✗ Branch 425 not taken.
✗ Branch 426 not taken.
✗ Branch 427 not taken.
✓ Branch 428 taken 2365308 times.
✗ Branch 429 not taken.
✓ Branch 430 taken 561132 times.
✗ Branch 431 not taken.
✗ Branch 432 not taken.
✗ Branch 433 not taken.
✓ Branch 434 taken 225833 times.
✗ Branch 435 not taken.
✗ Branch 436 not taken.
✗ Branch 437 not taken.
✗ Branch 438 not taken.
✓ Branch 439 taken 22550639 times.
✓ Branch 440 taken 14110188 times.
✓ Branch 441 taken 125 times.
✓ Branch 442 taken 63717 times.
✗ Branch 443 not taken.
✗ Branch 444 not taken.
✓ Branch 445 taken 49182684 times.
✓ Branch 446 taken 14019927 times.
✗ Branch 447 not taken.
✗ Branch 448 not taken.
✗ Branch 449 not taken.
✗ Branch 450 not taken.
✗ Branch 451 not taken.
✗ Branch 452 not taken.
✗ Branch 453 not taken.
✗ Branch 454 not taken.
✗ Branch 455 not taken.
✗ Branch 456 not taken.
✗ Branch 457 not taken.
✗ Branch 458 not taken.
✗ Branch 459 not taken.
✗ Branch 460 not taken.
✗ Branch 461 not taken.
✗ Branch 462 not taken.
✗ Branch 463 not taken.
✗ Branch 464 not taken.
✗ Branch 465 not taken.
✗ Branch 466 not taken.
✗ Branch 467 not taken.
✗ Branch 468 not taken.
✗ Branch 469 not taken.
✗ Branch 470 not taken.
✗ Branch 471 not taken.
✗ Branch 472 not taken.
✗ Branch 473 not taken.
✗ Branch 474 not taken.
✗ Branch 475 not taken.
✗ Branch 476 not taken.
✗ Branch 477 not taken.
✗ Branch 478 not taken.
✗ Branch 479 not taken.
✗ Branch 480 not taken.
✗ Branch 481 not taken.
✗ Branch 482 not taken.
✗ Branch 483 not taken.
✗ Branch 484 not taken.
✗ Branch 485 not taken.
✗ Branch 486 not taken.
✓ Branch 487 taken 109824 times.
✗ Branch 488 not taken.
✗ Branch 489 not taken.
✗ Branch 490 not taken.
✗ Branch 491 not taken.
✗ Branch 492 not taken.
✗ Branch 493 not taken.
✗ Branch 494 not taken.
✗ Branch 495 not taken.
✗ Branch 496 not taken.
✗ Branch 497 not taken.
✗ Branch 498 not taken.
✗ Branch 499 not taken.
✗ Branch 500 not taken.
✓ Branch 501 taken 1 times.
✗ Branch 502 not taken.
✗ Branch 503 not taken.
✗ Branch 504 not taken.
✓ Branch 505 taken 910 times.
✓ Branch 506 taken 43250 times.
✗ Branch 507 not taken.
✓ Branch 508 taken 3 times.
✓ Branch 509 taken 4 times.
✗ Branch 510 not taken.
✗ Branch 511 not taken.
✗ Branch 512 not taken.
✗ Branch 513 not taken.
✗ Branch 514 not taken.
✗ Branch 515 not taken.
✗ Branch 516 not taken.
✗ Branch 517 not taken.
✗ Branch 518 not taken.
✗ Branch 519 not taken.
✗ Branch 520 not taken.
✗ Branch 521 not taken.
✗ Branch 522 not taken.
✗ Branch 523 not taken.
✗ Branch 524 not taken.
✓ Branch 525 taken 10246 times.
✓ Branch 526 taken 7214 times.
✓ Branch 527 taken 2272 times.
✓ Branch 528 taken 6637215 times.
✓ Branch 529 taken 1522143 times.
✓ Branch 530 taken 11315120 times.
✗ Branch 531 not taken.
✗ Branch 532 not taken.
✗ Branch 533 not taken.
✗ Branch 534 not taken.
✓ Branch 535 taken 1 times.
✓ Branch 536 taken 1 times.
✗ Branch 537 not taken.
✗ Branch 538 not taken.
✗ Branch 539 not taken.
✗ Branch 540 not taken.
✗ Branch 541 not taken.
✗ Branch 542 not taken.
✗ Branch 543 not taken.
✗ Branch 544 not taken.
✓ Branch 545 taken 6509791 times.
✗ Branch 546 not taken.
✗ Branch 547 not taken.
✓ Branch 548 taken 146 times.
✗ Branch 549 not taken.
✗ Branch 550 not taken.
✗ Branch 551 not taken.
✗ Branch 552 not taken.
✗ Branch 553 not taken.
✗ Branch 554 not taken.
✗ Branch 555 not taken.
✗ Branch 556 not taken.
✗ Branch 557 not taken.
✗ Branch 558 not taken.
✓ Branch 559 taken 16 times.
✗ Branch 560 not taken.
✗ Branch 561 not taken.
✗ Branch 562 not taken.
✓ Branch 563 taken 732975 times.
✗ Branch 564 not taken.
✗ Branch 565 not taken.
✗ Branch 566 not taken.
✗ Branch 567 not taken.
✗ Branch 568 not taken.
✗ Branch 569 not taken.
✗ Branch 570 not taken.
✗ Branch 571 not taken.
✗ Branch 572 not taken.
✗ Branch 573 not taken.
✗ Branch 574 not taken.
✓ Branch 575 taken 22016 times.
✗ Branch 576 not taken.
✗ Branch 577 not taken.
✗ Branch 578 not taken.
✗ Branch 579 not taken.
✗ Branch 580 not taken.
✓ Branch 581 taken 10673 times.
✗ Branch 582 not taken.
✗ Branch 583 not taken.
✗ Branch 584 not taken.
✗ Branch 585 not taken.
✗ Branch 586 not taken.
✗ Branch 587 not taken.
✓ Branch 588 taken 15654 times.
✓ Branch 589 taken 158257 times.
✓ Branch 590 taken 56823 times.
✓ Branch 591 taken 1340206 times.
✓ Branch 592 taken 2886839 times.
✓ Branch 593 taken 15644160 times.
✗ Branch 594 not taken.
✗ Branch 595 not taken.
✓ Branch 596 taken 25786 times.
✗ Branch 597 not taken.
✗ Branch 598 not taken.
✗ Branch 599 not taken.
✓ Branch 600 taken 755060 times.
✗ Branch 601 not taken.
✗ Branch 602 not taken.
✗ Branch 603 not taken.
✗ Branch 604 not taken.
✗ Branch 605 not taken.
✗ Branch 606 not taken.
✓ Branch 607 taken 427 times.
✗ Branch 608 not taken.
✗ Branch 609 not taken.
✗ Branch 610 not taken.
✗ Branch 611 not taken.
✗ Branch 612 not taken.
✗ Branch 613 not taken.
✗ Branch 614 not taken.
✗ Branch 615 not taken.
✗ Branch 616 not taken.
✗ Branch 617 not taken.
✗ Branch 618 not taken.
✗ Branch 619 not taken.
✗ Branch 620 not taken.
✗ Branch 621 not taken.
✗ Branch 622 not taken.
✗ Branch 623 not taken.
✗ Branch 624 not taken.
✗ Branch 625 not taken.
✗ Branch 626 not taken.
✗ Branch 627 not taken.
✗ Branch 628 not taken.
✗ Branch 629 not taken.
✗ Branch 630 not taken.
✗ Branch 631 not taken.
✗ Branch 632 not taken.
✗ Branch 633 not taken.
✗ Branch 634 not taken.
✗ Branch 635 not taken.
✗ Branch 636 not taken.
✗ Branch 637 not taken.
✗ Branch 638 not taken.
✗ Branch 639 not taken.
✗ Branch 640 not taken.
✗ Branch 641 not taken.
✗ Branch 642 not taken.
✗ Branch 643 not taken.
✗ Branch 644 not taken.
✗ Branch 645 not taken.
✗ Branch 646 not taken.
✗ Branch 647 not taken.
✗ Branch 648 not taken.
✗ Branch 649 not taken.
✗ Branch 650 not taken.
✗ Branch 651 not taken.
✗ Branch 652 not taken.
✗ Branch 653 not taken.
✗ Branch 654 not taken.
✗ Branch 655 not taken.
✗ Branch 656 not taken.
✗ Branch 657 not taken.
✗ Branch 658 not taken.
✗ Branch 659 not taken.
✗ Branch 660 not taken.
✓ Branch 661 taken 952310006 times.
✗ Branch 662 not taken.
✓ Branch 663 taken 749214842 times.
✗ Branch 664 not taken.
✓ Branch 665 taken 6076 times.
✓ Branch 666 taken 28819 times.
✓ Branch 667 taken 15036773 times.
✓ Branch 668 taken 14896055 times.
✓ Branch 669 taken 562181 times.
✗ Branch 670 not taken.
✓ Branch 671 taken 2929 times.
✗ Branch 672 not taken.
✗ Branch 673 not taken.
✓ Branch 674 taken 2402 times.
✗ Branch 675 not taken.
✗ Branch 676 not taken.
✗ Branch 677 not taken.
✗ Branch 678 not taken.
✗ Branch 679 not taken.
✓ Branch 680 taken 766680 times.
✗ Branch 681 not taken.
✓ Branch 682 taken 468 times.
✗ Branch 683 not taken.
✗ Branch 684 not taken.
✗ Branch 685 not taken.
✗ Branch 686 not taken.
✗ Branch 687 not taken.
✗ Branch 688 not taken.
✗ Branch 689 not taken.
✗ Branch 690 not taken.
✗ Branch 691 not taken.
✗ Branch 692 not taken.
✗ Branch 693 not taken.
✗ Branch 694 not taken.
✗ Branch 695 not taken.
✗ Branch 696 not taken.
✗ Branch 697 not taken.
✗ Branch 698 not taken.
✗ Branch 699 not taken.
✗ Branch 700 not taken.
✗ Branch 701 not taken.
✗ Branch 702 not taken.
✗ Branch 703 not taken.
✗ Branch 704 not taken.
✗ Branch 705 not taken.
✗ Branch 706 not taken.
✗ Branch 707 not taken.
✗ Branch 708 not taken.
✗ Branch 709 not taken.
✗ Branch 710 not taken.
✗ Branch 711 not taken.
✗ Branch 712 not taken.
✓ Branch 713 taken 53 times.
✗ Branch 714 not taken.
✗ Branch 715 not taken.
✗ Branch 716 not taken.
✗ Branch 717 not taken.
✗ Branch 718 not taken.
✓ Branch 719 taken 901 times.
✗ Branch 720 not taken.
✗ Branch 721 not taken.
✗ Branch 722 not taken.
✗ Branch 723 not taken.
✗ Branch 724 not taken.
✗ Branch 725 not taken.
✗ Branch 726 not taken.
✗ Branch 727 not taken.
✗ Branch 728 not taken.
✓ Branch 729 taken 140 times.
✓ Branch 730 taken 1765 times.
✗ Branch 731 not taken.
✗ Branch 732 not taken.
✗ Branch 733 not taken.
✗ Branch 734 not taken.
✗ Branch 735 not taken.
✗ Branch 736 not taken.
✗ Branch 737 not taken.
✗ Branch 738 not taken.
✗ Branch 739 not taken.
✗ Branch 740 not taken.
✗ Branch 741 not taken.
✗ Branch 742 not taken.
✗ Branch 743 not taken.
✓ Branch 744 taken 50207 times.
✗ Branch 745 not taken.
✓ Branch 746 taken 50207 times.
✓ Branch 747 taken 61651 times.
✓ Branch 748 taken 134799 times.
✓ Branch 749 taken 73148 times.
✗ Branch 750 not taken.
✗ Branch 751 not taken.
✓ Branch 752 taken 77690 times.
✗ Branch 753 not taken.
✗ Branch 754 not taken.
✗ Branch 755 not taken.
✗ Branch 756 not taken.
✗ Branch 757 not taken.
✗ Branch 758 not taken.
✓ Branch 759 taken 426414 times.
✓ Branch 760 taken 436097 times.
✗ Branch 761 not taken.
✓ Branch 762 taken 410674 times.
✗ Branch 763 not taken.
✗ Branch 764 not taken.
✓ Branch 765 taken 5123278 times.
✗ Branch 766 not taken.
✓ Branch 767 taken 165739 times.
✗ Branch 768 not taken.
✓ Branch 769 taken 1128791 times.
✓ Branch 770 taken 472577 times.
✗ Branch 771 not taken.
✓ Branch 772 taken 532410 times.
✓ Branch 773 taken 3169 times.
✓ Branch 774 taken 13200 times.
✓ Branch 775 taken 5408 times.
✓ Branch 776 taken 39139 times.
✗ Branch 777 not taken.
✗ Branch 778 not taken.
✓ Branch 779 taken 404 times.
✗ Branch 780 not taken.
✓ Branch 781 taken 17986 times.
✗ Branch 782 not taken.
✗ Branch 783 not taken.
✓ Branch 784 taken 6086 times.
✓ Branch 785 taken 383015 times.
✓ Branch 786 taken 383015 times.
✓ Branch 787 taken 427914 times.
✓ Branch 788 taken 427914 times.
✓ Branch 789 taken 226198 times.
✗ Branch 790 not taken.
✓ Branch 791 taken 1504060 times.
✓ Branch 792 taken 1486185 times.
✓ Branch 793 taken 1058431 times.
✗ Branch 794 not taken.
✓ Branch 795 taken 1035972 times.
✓ Branch 796 taken 603413 times.
✓ Branch 797 taken 2061476 times.
✓ Branch 798 taken 2062453 times.
✗ Branch 799 not taken.
✗ Branch 800 not taken.
✗ Branch 801 not taken.
✓ Branch 802 taken 2061449 times.
✓ Branch 803 taken 75622 times.
✗ Branch 804 not taken.
✗ Branch 805 not taken.
✗ Branch 806 not taken.
✗ Branch 807 not taken.
✗ Branch 808 not taken.
✗ Branch 809 not taken.
✓ Branch 810 taken 527244 times.
✗ Branch 811 not taken.
✓ Branch 812 taken 22516459 times.
✗ Branch 813 not taken.
✓ Branch 814 taken 598 times.
✗ Branch 815 not taken.
✓ Branch 816 taken 3670410 times.
✓ Branch 817 taken 167669 times.
✓ Branch 818 taken 268246 times.
✗ Branch 819 not taken.
✓ Branch 820 taken 11380654 times.
✗ Branch 821 not taken.
✗ Branch 822 not taken.
✓ Branch 823 taken 6431340 times.
✗ Branch 824 not taken.
✗ Branch 825 not taken.
✗ Branch 826 not taken.
✗ Branch 827 not taken.
✗ Branch 828 not taken.
✗ Branch 829 not taken.
✗ Branch 830 not taken.
✗ Branch 831 not taken.
✗ Branch 832 not taken.
✗ Branch 833 not taken.
✗ Branch 834 not taken.
✗ Branch 835 not taken.
✗ Branch 836 not taken.
✓ Branch 837 taken 1267145 times.
✓ Branch 838 taken 218 times.
✗ Branch 839 not taken.
✗ Branch 840 not taken.
✗ Branch 841 not taken.
✗ Branch 842 not taken.
✗ Branch 843 not taken.
✗ Branch 844 not taken.
✗ Branch 845 not taken.
✗ Branch 846 not taken.
✗ Branch 847 not taken.
✓ Branch 848 taken 191517 times.
✓ Branch 849 taken 1218351 times.
✗ Branch 850 not taken.
✗ Branch 851 not taken.
✗ Branch 852 not taken.
✓ Branch 853 taken 18739404 times.
✓ Branch 854 taken 5919526 times.
✗ Branch 855 not taken.
✗ Branch 856 not taken.
✗ Branch 857 not taken.
✗ Branch 858 not taken.
✗ Branch 859 not taken.
✗ Branch 860 not taken.
✗ Branch 861 not taken.
✗ Branch 862 not taken.
✗ Branch 863 not taken.
✗ Branch 864 not taken.
✓ Branch 865 taken 1764243 times.
✓ Branch 866 taken 1019 times.
✓ Branch 867 taken 255560 times.
✗ Branch 868 not taken.
✓ Branch 869 taken 741668 times.
✓ Branch 870 taken 95414 times.
✓ Branch 871 taken 9482 times.
✓ Branch 872 taken 37 times.
✓ Branch 873 taken 27341446 times.
✓ Branch 874 taken 2709583 times.
✓ Branch 875 taken 3906008 times.
✓ Branch 876 taken 26493201 times.
✓ Branch 877 taken 2974800 times.
✓ Branch 878 taken 96784 times.
✗ Branch 879 not taken.
✓ Branch 880 taken 13758809 times.
✓ Branch 881 taken 2272124 times.
✓ Branch 882 taken 5866709 times.
✓ Branch 883 taken 449777 times.
✓ Branch 884 taken 421915 times.
✓ Branch 885 taken 6342577 times.
✗ Branch 886 not taken.
✗ Branch 887 not taken.
✗ Branch 888 not taken.
✗ Branch 889 not taken.
✗ Branch 890 not taken.
✗ Branch 891 not taken.
✗ Branch 892 not taken.
✗ Branch 893 not taken.
✗ Branch 894 not taken.
✗ Branch 895 not taken.
✗ Branch 896 not taken.
✗ Branch 897 not taken.
✗ Branch 898 not taken.
✗ Branch 899 not taken.
✗ Branch 900 not taken.
✓ Branch 901 taken 390022 times.
✗ Branch 902 not taken.
✗ Branch 903 not taken.
✗ Branch 904 not taken.
✓ Branch 905 taken 229611 times.
✓ Branch 906 taken 91 times.
✗ Branch 907 not taken.
✗ Branch 908 not taken.
✗ Branch 909 not taken.
✗ Branch 910 not taken.
✗ Branch 911 not taken.
✗ Branch 912 not taken.
✗ Branch 913 not taken.
✗ Branch 914 not taken.
✗ Branch 915 not taken.
✗ Branch 916 not taken.
✗ Branch 917 not taken.
✗ Branch 918 not taken.
✗ Branch 919 not taken.
✗ Branch 920 not taken.
✗ Branch 921 not taken.
✗ Branch 922 not taken.
✗ Branch 923 not taken.
✗ Branch 924 not taken.
✗ Branch 925 not taken.
✗ Branch 926 not taken.
✗ Branch 927 not taken.
✗ Branch 928 not taken.
✗ Branch 929 not taken.
✗ Branch 930 not taken.
✗ Branch 931 not taken.
✗ Branch 932 not taken.
✗ Branch 933 not taken.
✗ Branch 934 not taken.
✗ Branch 935 not taken.
✗ Branch 936 not taken.
✗ Branch 937 not taken.
✗ Branch 938 not taken.
✗ Branch 939 not taken.
✗ Branch 940 not taken.
✗ Branch 941 not taken.
✗ Branch 942 not taken.
✗ Branch 943 not taken.
✗ Branch 944 not taken.
✗ Branch 945 not taken.
✗ Branch 946 not taken.
✗ Branch 947 not taken.
✗ Branch 948 not taken.
✗ Branch 949 not taken.
✗ Branch 950 not taken.
✗ Branch 951 not taken.
✗ Branch 952 not taken.
✗ Branch 953 not taken.
✗ Branch 954 not taken.
✓ Branch 955 taken 6 times.
✓ Branch 956 taken 6 times.
✗ Branch 957 not taken.
✗ Branch 958 not taken.
✗ Branch 959 not taken.
✗ Branch 960 not taken.
✓ Branch 961 taken 128 times.
✓ Branch 962 taken 128 times.
✓ Branch 963 taken 128 times.
✗ Branch 964 not taken.
✗ Branch 965 not taken.
✗ Branch 966 not taken.
✓ Branch 967 taken 5 times.
✓ Branch 968 taken 5 times.
✓ Branch 969 taken 5 times.
✓ Branch 970 taken 389 times.
✓ Branch 971 taken 389 times.
✓ Branch 972 taken 5 times.
✓ Branch 973 taken 5 times.
✓ Branch 974 taken 5 times.
✓ Branch 975 taken 5 times.
✓ Branch 976 taken 70 times.
✗ Branch 977 not taken.
✓ Branch 978 taken 32 times.
✗ Branch 979 not taken.
✗ Branch 980 not taken.
✗ Branch 981 not taken.
✗ Branch 982 not taken.
✓ Branch 983 taken 5 times.
✓ Branch 984 taken 5 times.
✓ Branch 985 taken 5 times.
✓ Branch 986 taken 5 times.
✗ Branch 987 not taken.
✓ Branch 988 taken 32773 times.
✓ Branch 989 taken 1800 times.
✗ Branch 990 not taken.
✗ Branch 991 not taken.
✗ Branch 992 not taken.
✗ Branch 993 not taken.
✗ Branch 994 not taken.
✗ Branch 995 not taken.
✗ Branch 996 not taken.
✗ Branch 997 not taken.
✗ Branch 998 not taken.
✗ Branch 999 not taken.
✗ Branch 1000 not taken.
✗ Branch 1001 not taken.
✗ Branch 1002 not taken.
✗ Branch 1003 not taken.
✗ Branch 1004 not taken.
✓ Branch 1005 taken 4767898 times.
✓ Branch 1006 taken 4654485 times.
✓ Branch 1007 taken 5945377 times.
✓ Branch 1008 taken 2538431 times.
✓ Branch 1009 taken 345816 times.
✓ Branch 1010 taken 85947 times.
✗ Branch 1011 not taken.
✗ Branch 1012 not taken.
✗ Branch 1013 not taken.
✗ Branch 1014 not taken.
✗ Branch 1015 not taken.
✗ Branch 1016 not taken.
✗ Branch 1017 not taken.
✗ Branch 1018 not taken.
✗ Branch 1019 not taken.
✗ Branch 1020 not taken.
✗ Branch 1021 not taken.
✗ Branch 1022 not taken.
✗ Branch 1023 not taken.
✓ Branch 1024 taken 24 times.
✗ Branch 1025 not taken.
✗ Branch 1026 not taken.
✗ Branch 1027 not taken.
✗ Branch 1028 not taken.
✗ Branch 1029 not taken.
✗ Branch 1030 not taken.
✗ Branch 1031 not taken.
✗ Branch 1032 not taken.
✗ Branch 1033 not taken.
✗ Branch 1034 not taken.
✗ Branch 1035 not taken.
✗ Branch 1036 not taken.
✗ Branch 1037 not taken.
✗ Branch 1038 not taken.
✗ Branch 1039 not taken.
✗ Branch 1040 not taken.
✗ Branch 1041 not taken.
✗ Branch 1042 not taken.
✗ Branch 1043 not taken.
✗ Branch 1044 not taken.
✗ Branch 1045 not taken.
✗ Branch 1046 not taken.
✗ Branch 1047 not taken.
✗ Branch 1048 not taken.
✗ Branch 1049 not taken.
✗ Branch 1050 not taken.
✗ Branch 1051 not taken.
✗ Branch 1052 not taken.
✗ Branch 1053 not taken.
✗ Branch 1054 not taken.
✗ Branch 1055 not taken.
✗ Branch 1056 not taken.
✓ Branch 1057 taken 11261 times.
✓ Branch 1058 taken 11261 times.
✓ Branch 1059 taken 33759 times.
✓ Branch 1060 taken 11044 times.
✓ Branch 1061 taken 4546 times.
✗ Branch 1062 not taken.
✗ Branch 1063 not taken.
✗ Branch 1064 not taken.
✗ Branch 1065 not taken.
✓ Branch 1066 taken 4546 times.
✗ Branch 1067 not taken.
✗ Branch 1068 not taken.
✓ Branch 1069 taken 4890 times.
✗ Branch 1070 not taken.
✗ Branch 1071 not taken.
✓ Branch 1072 taken 22172 times.
✗ Branch 1073 not taken.
✗ Branch 1074 not taken.
✗ Branch 1075 not taken.
✗ Branch 1076 not taken.
✗ Branch 1077 not taken.
✗ Branch 1078 not taken.
✗ Branch 1079 not taken.
✗ Branch 1080 not taken.
✗ Branch 1081 not taken.
✓ Branch 1082 taken 66 times.
✓ Branch 1083 taken 1636 times.
✓ Branch 1084 taken 568 times.
✓ Branch 1085 taken 136 times.
✗ Branch 1086 not taken.
✗ Branch 1087 not taken.
✗ Branch 1088 not taken.
✗ Branch 1089 not taken.
✗ Branch 1090 not taken.
✗ Branch 1091 not taken.
✗ Branch 1092 not taken.
✗ Branch 1093 not taken.
✗ Branch 1094 not taken.
✗ Branch 1095 not taken.
✗ Branch 1096 not taken.
✗ Branch 1097 not taken.
✗ Branch 1098 not taken.
✗ Branch 1099 not taken.
✗ Branch 1100 not taken.
✗ Branch 1101 not taken.
✗ Branch 1102 not taken.
✗ Branch 1103 not taken.
✗ Branch 1104 not taken.
✗ Branch 1105 not taken.
✗ Branch 1106 not taken.
✗ Branch 1107 not taken.
✗ Branch 1108 not taken.
✗ Branch 1109 not taken.
✗ Branch 1110 not taken.
✗ Branch 1111 not taken.
✗ Branch 1112 not taken.
✗ Branch 1113 not taken.
✗ Branch 1114 not taken.
✗ Branch 1115 not taken.
✗ Branch 1116 not taken.
✗ Branch 1117 not taken.
✗ Branch 1118 not taken.
✗ Branch 1119 not taken.
✗ Branch 1120 not taken.
✗ Branch 1121 not taken.
✗ Branch 1122 not taken.
✗ Branch 1123 not taken.
✗ Branch 1124 not taken.
✗ Branch 1125 not taken.
✗ Branch 1126 not taken.
✗ Branch 1127 not taken.
✗ Branch 1128 not taken.
✗ Branch 1129 not taken.
✗ Branch 1130 not taken.
✗ Branch 1131 not taken.
✗ Branch 1132 not taken.
✗ Branch 1133 not taken.
✗ Branch 1134 not taken.
✗ Branch 1135 not taken.
✗ Branch 1136 not taken.
✗ Branch 1137 not taken.
✗ Branch 1138 not taken.
✗ Branch 1139 not taken.
✗ Branch 1140 not taken.
✗ Branch 1141 not taken.
✗ Branch 1142 not taken.
✗ Branch 1143 not taken.
✗ Branch 1144 not taken.
✗ Branch 1145 not taken.
✗ Branch 1146 not taken.
✗ Branch 1147 not taken.
✗ Branch 1148 not taken.
✗ Branch 1149 not taken.
✗ Branch 1150 not taken.
✗ Branch 1151 not taken.
✗ Branch 1152 not taken.
✗ Branch 1153 not taken.
✗ Branch 1154 not taken.
✗ Branch 1155 not taken.
✗ Branch 1156 not taken.
✗ Branch 1157 not taken.
✗ Branch 1158 not taken.
✗ Branch 1159 not taken.
✗ Branch 1160 not taken.
✗ Branch 1161 not taken.
✗ Branch 1162 not taken.
✗ Branch 1163 not taken.
✗ Branch 1164 not taken.
✗ Branch 1165 not taken.
✗ Branch 1166 not taken.
✗ Branch 1167 not taken.
✗ Branch 1168 not taken.
✗ Branch 1169 not taken.
✗ Branch 1170 not taken.
✗ Branch 1171 not taken.
✗ Branch 1172 not taken.
✗ Branch 1173 not taken.
✗ Branch 1174 not taken.
✗ Branch 1175 not taken.
✗ Branch 1176 not taken.
✗ Branch 1177 not taken.
✗ Branch 1178 not taken.
✗ Branch 1179 not taken.
✗ Branch 1180 not taken.
✗ Branch 1181 not taken.
✗ Branch 1182 not taken.
✗ Branch 1183 not taken.
✗ Branch 1184 not taken.
✗ Branch 1185 not taken.
✗ Branch 1186 not taken.
✗ Branch 1187 not taken.
✗ Branch 1188 not taken.
✗ Branch 1189 not taken.
✗ Branch 1190 not taken.
✗ Branch 1191 not taken.
✗ Branch 1192 not taken.
✗ Branch 1193 not taken.
✗ Branch 1194 not taken.
✗ Branch 1195 not taken.
✗ Branch 1196 not taken.
✗ Branch 1197 not taken.
✗ Branch 1198 not taken.
✗ Branch 1199 not taken.
✗ Branch 1200 not taken.
✗ Branch 1201 not taken.
✗ Branch 1202 not taken.
✗ Branch 1203 not taken.
✗ Branch 1204 not taken.
✗ Branch 1205 not taken.
✗ Branch 1206 not taken.
✗ Branch 1207 not taken.
✗ Branch 1208 not taken.
✗ Branch 1209 not taken.
✗ Branch 1210 not taken.
✗ Branch 1211 not taken.
✗ Branch 1212 not taken.
✗ Branch 1213 not taken.
✗ Branch 1214 not taken.
✗ Branch 1215 not taken.
✗ Branch 1216 not taken.
✗ Branch 1217 not taken.
✗ Branch 1218 not taken.
✗ Branch 1219 not taken.
✗ Branch 1220 not taken.
✗ Branch 1221 not taken.
✗ Branch 1222 not taken.
✗ Branch 1223 not taken.
✗ Branch 1224 not taken.
✗ Branch 1225 not taken.
✗ Branch 1226 not taken.
✗ Branch 1227 not taken.
✗ Branch 1228 not taken.
✗ Branch 1229 not taken.
✗ Branch 1230 not taken.
✗ Branch 1231 not taken.
✗ Branch 1232 not taken.
✗ Branch 1233 not taken.
✗ Branch 1234 not taken.
✗ Branch 1235 not taken.
✗ Branch 1236 not taken.
✗ Branch 1237 not taken.
✗ Branch 1238 not taken.
✗ Branch 1239 not taken.
✗ Branch 1240 not taken.
✗ Branch 1241 not taken.
✗ Branch 1242 not taken.
✗ Branch 1243 not taken.
✗ Branch 1244 not taken.
✗ Branch 1245 not taken.
✗ Branch 1246 not taken.
✗ Branch 1247 not taken.
✗ Branch 1248 not taken.
✗ Branch 1249 not taken.
✗ Branch 1250 not taken.
✗ Branch 1251 not taken.
✗ Branch 1252 not taken.
✗ Branch 1253 not taken.
✗ Branch 1254 not taken.
✗ Branch 1255 not taken.
✗ Branch 1256 not taken.
✗ Branch 1257 not taken.
✗ Branch 1258 not taken.
✗ Branch 1259 not taken.
✗ Branch 1260 not taken.
✗ Branch 1261 not taken.
✗ Branch 1262 not taken.
✗ Branch 1263 not taken.
✗ Branch 1264 not taken.
✗ Branch 1265 not taken.
✗ Branch 1266 not taken.
2760569860 switch(arg)
3499 {
3500
3501 case INCQST:
3502 {
3503 //zprint2("Incrementing Quest\n");
3504 int32_t newqst = 0;
3505 if ( game->get_quest() < 255 ) //255 is a custom quest
3506 {
3507 newqst = (game->get_quest()+1);
3508 }
3509 else
3510 {
3511 newqst = 1;
3512 }
3513 //zprint2("newqst is: %d\n", newqst);
3514 if ( newqst < 11 )
3515 {
3516
3517 ret = newqst * 10000;
3518 Quit = qINCQST;
3519 //ending();
3520
3521 }
3522 else ret = -10000;
3523 break;
3524 }
3525 //Debug->Null()
3526 case DONULL:
3527 ret = 0;
3528 break;
3529 case DEBUGTESTING:
3530 43 ret = use_testingst_start ? 10000 : 0;
3531 43 break;
3532
3533 //debug ri->d[]
3534 case DEBUGD:
3535 {
3536 int32_t a = ri->d[rINDEX] / 10000;
3537 ret = ri->d[a] * 10000;
3538 break;
3539 }
3540
3541 ///----------------------------------------------------------------------------------------------------//
3542 //FFC Variables
3543 case DATA:
3544
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4436597 times.
4436597 if(BC::checkFFC(ri->ffcref, "ffc->Data") == SH::_NoError)
3545 4436597 ret = tmpscr->ffcs[ri->ffcref].getData() *10000;
3546 4436597 break;
3547
3548 case FFSCRIPT:
3549
2/2
✓ Branch 0 taken 212 times.
✓ Branch 1 taken 468470856 times.
468471068 if(BC::checkFFC(ri->ffcref, "ffc->Script") == SH::_NoError)
3550 468470856 ret = tmpscr->ffcs[ri->ffcref].script*10000;
3551 468471068 break;
3552
3553 case FCSET:
3554
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1183551 times.
1183551 if(BC::checkFFC(ri->ffcref, "ffc->CSet") == SH::_NoError)
3555 1183551 ret = tmpscr->ffcs[ri->ffcref].cset*10000;
3556 1183551 break;
3557
3558 case DELAY:
3559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(BC::checkFFC(ri->ffcref, "ffc->Delay") == SH::_NoError)
3560 5 ret = tmpscr->ffcs[ri->ffcref].delay*10000;
3561 5 break;
3562
3563 case FX:
3564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8343962 times.
8343962 if(BC::checkFFC(ri->ffcref, "ffc->X") == SH::_NoError)
3565 8343962 ret = tmpscr->ffcs[ri->ffcref].x.getZLong();
3566 8343962 break;
3567
3568 case FY:
3569
1/2
✓ Branch 0 taken 7892556 times.
✗ Branch 1 not taken.
7892556 if(BC::checkFFC(ri->ffcref, "ffc->Y") == SH::_NoError)
3570 7892556 ret = tmpscr->ffcs[ri->ffcref].y.getZLong();
3571 7892556 break;
3572
3573 case XD:
3574
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(BC::checkFFC(ri->ffcref, "ffc->Vx") == SH::_NoError)
3575 35 ret = tmpscr->ffcs[ri->ffcref].vx.getZLong();
3576 35 break;
3577
3578 case YD:
3579
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(BC::checkFFC(ri->ffcref, "ffc->Vy") == SH::_NoError)
3580 35 ret = tmpscr->ffcs[ri->ffcref].vy.getZLong();
3581 35 break;
3582 case FFCID:
3583 if(BC::checkFFC(ri->ffcref, "ffc->ID") == SH::_NoError)
3584 ret=(ri->ffcref*10000)+10000;
3585 break;
3586
3587 case XD2:
3588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(BC::checkFFC(ri->ffcref, "ffc->Ax") == SH::_NoError)
3589 35 ret = tmpscr->ffcs[ri->ffcref].ax.getZLong();
3590 35 break;
3591
3592 case YD2:
3593
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(BC::checkFFC(ri->ffcref, "ffc->Ay") == SH::_NoError)
3594 35 ret = tmpscr->ffcs[ri->ffcref].ay.getZLong();
3595 35 break;
3596
3597 case FFFLAGSD:
3598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2177905 times.
2177905 if(BC::checkFFC(ri->ffcref, "ffc->Flags[]") == SH::_NoError)
3599 2177905 ret=((tmpscr->ffcs[ri->ffcref].flags >> (ri->d[rINDEX] / 10000))&1) ? 10000 : 0;
3600 2177905 break;
3601
3602 case FFCWIDTH:
3603
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 103 times.
103 if(BC::checkFFC(ri->ffcref, "ffc->EffectWidth") == SH::_NoError)
3604 103 ret=(tmpscr->ffcs[ri->ffcref].hit_width*10000);
3605 103 break;
3606
3607 case FFCHEIGHT:
3608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98 times.
98 if(BC::checkFFC(ri->ffcref, "ffc->EffectHeight") == SH::_NoError)
3609 98 ret=(tmpscr->ffcs[ri->ffcref].hit_height*10000);
3610 98 break;
3611
3612 case FFTWIDTH:
3613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2593791 times.
2593791 if(BC::checkFFC(ri->ffcref, "ffc->TileWidth") == SH::_NoError)
3614 2593791 ret=(tmpscr->ffcs[ri->ffcref].txsz*10000);
3615 2593791 break;
3616
3617 case FFTHEIGHT:
3618
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2594062 times.
2594062 if(BC::checkFFC(ri->ffcref, "ffc->TileHeight") == SH::_NoError)
3619 2594062 ret=(tmpscr->ffcs[ri->ffcref].tysz*10000);
3620 2594062 break;
3621
3622 case FFLINK:
3623 if(BC::checkFFC(ri->ffcref, "ffc->Link") == SH::_NoError)
3624 ret=(tmpscr->ffcs[ri->ffcref].link)*10000;
3625 break;
3626
3627 case FFMISCD:
3628 {
3629 6076 int32_t a = ri->d[rINDEX] / 10000;
3630
3631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6076 times.
6076 if(BC::checkMisc(a, "ffc->Misc") != SH::_NoError)
3632 ret = -10000;
3633 else
3634 {
3635
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6076 times.
6076 if(BC::checkFFC(ri->ffcref, "ffc->Misc[]") == SH::_NoError)
3636 6076 ret = ffmisc[ri->ffcref][a];
3637 }
3638 }
3639 6076 break;
3640
3641 case FFINITDD:
3642 {
3643 28819 int32_t a = ri->d[rINDEX] / 10000;
3644
3645
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28819 times.
28819 if(BC::checkBounds(a, 0, 7, "ffc->InitD") != SH::_NoError)
3646 ret = -10000;
3647 else
3648 {
3649
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 28802 times.
28819 if(BC::checkFFC(ri->ffcref, "ffc->InitD[]") == SH::_NoError)
3650 28802 ret = tmpscr->ffcs[ri->ffcref].initd[a];
3651 }
3652 }
3653 28819 break;
3654
3655 ///----------------------------------------------------------------------------------------------------//
3656 //Hero's Variables
3657 case LINKX:
3658 {
3659
2/2
✓ Branch 0 taken 1448216 times.
✓ Branch 1 taken 13588557 times.
15036773 if (get_qr(qr_SPRITEXY_IS_FLOAT))
3660 {
3661 //double lx = (double)Hero.getX();
3662 //Z_scripterrlog("lx: %f\n", lx);
3663
3664 //ret = lx * 10000;
3665 //zfix lx = Hero.getX();
3666 //Z_scripterrlog("lx: %d\n", lx);
3667 1448216 ret = Hero.getX().getZLong();
3668 1448216 }
3669 13588557 else ret = int32_t(Hero.getX()) * 10000;
3670
3671 15036773 break;
3672 }
3673
3674 case LINKCSET:
3675 {
3676 1282 ret = Hero.cs * 10000;
3677 1282 break;
3678 }
3679 case LINKY:
3680 {
3681
2/2
✓ Branch 0 taken 1414258 times.
✓ Branch 1 taken 13481797 times.
14896055 if (get_qr(qr_SPRITEXY_IS_FLOAT))
3682 {
3683 1414258 ret = Hero.getY().getZLong();
3684 1414258 }
3685 13481797 else ret = int32_t(Hero.getY()) * 10000;
3686
3687 14896055 break;
3688 }
3689 case LINKZ:
3690 {
3691
2/2
✓ Branch 0 taken 93233 times.
✓ Branch 1 taken 468948 times.
562181 if (get_qr(qr_SPRITEXY_IS_FLOAT))
3692 {
3693 93233 ret = Hero.getZ().getZLong();
3694 93233 }
3695 468948 else ret = int32_t(Hero.getZ()) * 10000;
3696
3697 562181 break;
3698 }
3699 case LINKJUMP:
3700 // -fall/100*10000, but doing it that way screwed up the result
3701 641181 ret = Hero.getFall().getZLong() / -100;
3702 641181 break;
3703
3704 case HEROFAKEJUMP:
3705 ret = Hero.getFakeFall().getZLong() / -100;
3706 break;
3707
3708 case LINKDIR:
3709 756380 ret=(int32_t)(Hero.dir)*10000;
3710 756380 break;
3711
3712 case LINKHITDIR:
3713 ret=(int32_t)(Hero.getHitDir())*10000;
3714 break;
3715
3716 case LINKHP:
3717 15442165 ret=(int32_t)(game->get_life())*10000;
3718 15442165 break;
3719
3720 case LINKGRAVITY:
3721 ret = ( (Hero.moveflags & FLAG_OBEYS_GRAV) ? 10000 : 0 );
3722 break;
3723
3724 case HERONOSTEPFORWARD:
3725 ret = ( (FFCore.nostepforward) ? 10000 : 0 );
3726 break;
3727
3728 case LINKMP:
3729 2112268 ret=(int32_t)(game->get_magic())*10000;
3730 2112268 break;
3731
3732 case LINKMAXHP:
3733 655865 ret=(int32_t)(game->get_maxlife())*10000;
3734 655865 break;
3735
3736 case LINKMAXMP:
3737 552027 ret=(int32_t)(game->get_maxmagic())*10000;
3738 552027 break;
3739
3740 case LINKACTION:
3741 {
3742 //Z_scripterrlog("The present FFCore action is: %d\n", FFCore.getHeroAction());
3743 //int32_t act = FFCore.getHeroAction() * 10000;
3744 44790481 ret = FFCore.getHeroAction() * 10000;
3745 //Z_scripterrlog("The present 'action' return value is: %d\n", act);
3746 //ret = act;
3747 //ret=(int32_t)(Hero.getAction())*10000;
3748 44790481 break;
3749 }
3750
3751 case HEROHEALTHBEEP:
3752 {
3753 //Z_scripterrlog("The present FFCore action is: %d\n", FFCore.getHeroAction());
3754 //int32_t act = FFCore.getHeroAction() * 10000;
3755 ret = heart_beep ? ( heart_beep_timer * 10000 ) : 0;
3756 //Z_scripterrlog("The present 'action' return value is: %d\n", act);
3757 //ret = act;
3758 //ret=(int32_t)(Hero.getAction())*10000;
3759 break;
3760 }
3761
3762 case LINKHELD:
3763 17 ret = (int32_t)(Hero.getHeldItem())*10000;
3764 17 break;
3765
3766 case LINKITEMD:
3767 19585851 ret = game->item[vbound(ri->d[rINDEX]/10000, 0, MAXITEMS-1)] ? 10000 : 0;
3768 19585851 break;
3769
3770 case HEROSTEPS:
3771 ret = lsteps[vbound(ri->d[rINDEX]/10000, 0, 7)] * 10000;
3772 break;
3773
3774 case HEROSTEPRATE:
3775 5424 ret = Hero.getStepRate() * 10000;
3776 5424 break;
3777
3778 case LINKEQUIP:
3779 801723 ret = ((Awpn&0xFF)|((Bwpn&0xFF)<<8))*10000;
3780 801723 break;
3781
3782 case LINKINVIS:
3783 557644 ret = (((int32_t)(Hero.getDontDraw())) ? 10000 : 0);
3784 557644 break;
3785
3786 case LINKINVINC:
3787 623338 ret = (int32_t)(Hero.scriptcoldet)*10000;
3788 623338 break;
3789
3790 case LINKENGINEANIMATE:
3791 ret = (int32_t)(Hero.do_animation)*10000;
3792 break;
3793
3794 case LINKLADDERX:
3795 ret=(int32_t)(Hero.getLadderX())*10000;
3796 break;
3797
3798 case LINKLADDERY:
3799 ret=(int32_t)(Hero.getLadderY())*10000;
3800 break;
3801
3802 case LINKSWORDJINX:
3803 280566 ret = (int32_t)(Hero.getSwordClk())*10000;
3804 280566 break;
3805
3806 case LINKITEMJINX:
3807 481556 ret = (int32_t)(Hero.getItemClk())*10000;
3808 481556 break;
3809
3810 case LINKDRUNK:
3811 ret = (int32_t)(Hero.DrunkClock())*10000;
3812 break;
3813
3814 case LINKMISCD:
3815 6213788 ret = (int32_t)(Hero.miscellaneous[vbound(ri->d[rINDEX]/10000,0,31)]); //Was this buffed before? -Z
3816 6213788 break;
3817
3818
3819 case LINKHITBY:
3820 {
3821 2929 int32_t indx = ri->d[rINDEX]/10000;
3822
1/3
✓ Branch 0 taken 2929 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
2929 switch(indx)
3823 {
3824 //screen indices of objects
3825 case 0:
3826 case 1:
3827 case 2:
3828 case 3:
3829 case 8:
3830 case 9:
3831 case 10:
3832 case 11:
3833 case 12:
3834 case 16:
3835 {
3836 2929 ret = (int32_t)(Hero.gethitHeroUID(indx))* 10000;
3837 2929 break;
3838 }
3839 //uids of objects
3840 case 4:
3841 case 5:
3842 case 6:
3843 case 7:
3844 case 13:
3845 case 14:
3846 case 15:
3847 {
3848 ret = (int32_t)(Hero.gethitHeroUID(indx)); //do not multiply by 10000! UIDs are not *10000!
3849 break;
3850 }
3851 default: { Z_scripterrlog("Invalid index passed to Player->HitBy[%d]/n", indx); ret = -1; break; }
3852 }
3853 2929 break;
3854 }
3855 case LINKDEFENCE:
3856 ret = (int32_t)(Hero.get_defence(vbound(ri->d[rINDEX]/10000,0,255)))* 10000;
3857 break;
3858
3859
3860 case LINKROTATION:
3861 if ( get_qr(qr_OLDSPRITEDRAWS) )
3862 {
3863 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
3864 "Player->Rotation");
3865 ret = -1; break;
3866 }
3867 ret = (int32_t)(Hero.rotation)*10000;
3868 break;
3869
3870 case LINKSCALE:
3871 {
3872 if ( get_qr(qr_OLDSPRITEDRAWS) )
3873 {
3874 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
3875 "Player->Scale");
3876 ret = -1; break;
3877 }
3878 //al_trace("Player's scale is: %d\n", Hero.scale);
3879 ret = (int32_t)(Hero.scale*100.0);
3880 break;
3881 }
3882
3883
3884 case LINKHXOFS:
3885 206522 ret = (int32_t)(Hero.hxofs)*10000;
3886 206522 break;
3887
3888 case LINKHYOFS:
3889 206522 ret = (int32_t)(Hero.hyofs)*10000;
3890 206522 break;
3891
3892 case LINKXOFS:
3893 ret = (int32_t)(Hero.xofs)*10000;
3894 break;
3895
3896 case LINKYOFS:
3897
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2402 times.
2402 ret = (int32_t)(Hero.yofs-(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset))*10000;
3898 2402 break;
3899
3900 case HEROSHADOWXOFS:
3901 ret = (int32_t)(Hero.shadowxofs)*10000;
3902 break;
3903
3904 case HEROSHADOWYOFS:
3905 ret = (int32_t)(Hero.shadowyofs)*10000;
3906 break;
3907
3908 case HEROTOTALDYOFFS:
3909 ret = 10000*(((int32_t)(Hero.yofs-(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)))
3910 + ((Hero.switch_hooked && Hero.switchhookstyle == swRISE)
3911 ? -(8-(abs(Hero.switchhookclk-32)/4)) : 0));
3912 break;
3913
3914 case LINKZOFS:
3915 ret = (int32_t)(Hero.zofs)*10000;
3916 break;
3917
3918 case LINKHXSZ:
3919 206547 ret = (int32_t)(Hero.hit_width)*10000;
3920 206547 break;
3921
3922 case LINKHYSZ:
3923 206547 ret = (int32_t)(Hero.hit_height)*10000;
3924 206547 break;
3925
3926 case LINKHZSZ:
3927 173466 ret = (int32_t)(Hero.hzsz)*10000;
3928 173466 break;
3929
3930 case LINKTXSZ:
3931 ret = (int32_t)(Hero.txsz)*10000;
3932 break;
3933
3934 case LINKTYSZ:
3935 ret = (int32_t)(Hero.tysz)*10000;
3936 break;
3937
3938 case LINKTILE:
3939 4636 ret = (int32_t)(Hero.tile)*10000;
3940 4636 break;
3941
3942 case LINKFLIP:
3943 ret = (int32_t)(Hero.flip)*10000;
3944 break;
3945
3946 case LINKINVFRAME:
3947 ret = (int32_t)Hero.getHClk()*10000;
3948 break;
3949
3950 case LINKCANFLICKER:
3951 ret= Hero.getCanFlicker()?10000:0;
3952 break;
3953 case LINKHURTSFX:
3954 ret = (int32_t)Hero.getHurtSFX()*10000;
3955 break;
3956
3957 /*
3958 case LINKUSINGITEM:
3959 ret = (int32_t)Hero.getDirectItem()*10000;
3960 break;
3961
3962 case LINKUSINGITEMA:
3963 ret = (int32_t)Hero.getDirectItemA()*10000;
3964 break;
3965
3966 case LINKUSINGITEMB:
3967 ret = (int32_t)Hero.getDirectItemB()*10000;
3968 break;
3969 */
3970
3971 case LINKEATEN:
3972 ret=(int32_t)Hero.getEaten()*10000;
3973 break;
3974 case LINKGRABBED:
3975 ret = Hero.inwallm ? 10000 : 0;
3976 break;
3977 case HEROBUNNY:
3978 ret = Hero.BunnyClock()*10000;
3979 break;
3980 case LINKPUSH:
3981 ret=(int32_t)Hero.getPushing()*10000;
3982 break;
3983 case LINKSTUN:
3984 ret=(int32_t)Hero.StunClock()*10000;
3985 break;
3986 case LINKSCRIPTTILE:
3987 2 ret=script_hero_sprite*10000;
3988 2 break;
3989
3990 case HEROSCRIPTCSET:
3991 ret=script_hero_cset*10000;
3992 break;
3993 case LINKSCRIPFLIP:
3994 ret=script_hero_flip*10000;
3995 break;
3996
3997
3998 case LINKITEMB:
3999 //Hero->setBButtonItem(vbound((value/10000),0,(MAXITEMS-1)));
4000 15348 ret = Bwpn*10000;
4001 15348 break;
4002
4003 case LINKITEMA:
4004 //Hero->setBButtonItem(vbound((value/10000),0,(MAXITEMS-1)));
4005 15551 ret = Awpn *10000;
4006 15551 break;
4007
4008 case LINKITEMX:
4009 //Hero->setBButtonItem(vbound((value/10000),0,(MAXITEMS-1)));
4010 12319 ret = Xwpn *10000;
4011 12319 break;
4012
4013 case LINKITEMY:
4014 //Hero->setBButtonItem(vbound((value/10000),0,(MAXITEMS-1)));
4015 13864 ret = Ywpn *10000;
4016 13864 break;
4017
4018 case LINKTILEMOD:
4019 ret = Hero.getTileModifier() * 10000;
4020 break;
4021
4022 case LINKDIAG:
4023 ret=Hero.getDiagMove()?10000:0;
4024 break;
4025
4026 case LINKBIGHITBOX:
4027 ret=Hero.getBigHitbox()?10000:0;
4028 break;
4029
4030 case LINKCLIMBING:
4031 ret = Hero.getOnSideviewLadder()?10000:0;
4032 break;
4033
4034 case HEROJUMPCOUNT:
4035 ret = Hero.extra_jump_count * 10000;
4036 break;
4037
4038 case HEROPULLDIR:
4039 ret = Hero.pit_pulldir * 10000;
4040 break;
4041
4042 case HEROPULLCLK:
4043 ret = Hero.pit_pullclk * 10000;
4044 break;
4045
4046 case HEROFALLCLK:
4047 88721 ret = Hero.fallclk * 10000;
4048 88721 break;
4049
4050 case HEROFALLCMB:
4051 ret = Hero.fallCombo * 10000;
4052 break;
4053
4054 case HERODROWNCLK:
4055 ret = Hero.drownclk * 10000;
4056 break;
4057
4058 case HERODROWNCMB:
4059 ret = Hero.drownCombo * 10000;
4060 break;
4061
4062 case HEROFAKEZ:
4063 {
4064 if (get_qr(qr_SPRITEXY_IS_FLOAT))
4065 {
4066 ret = Hero.getFakeZ().getZLong();
4067 }
4068 else ret = int32_t(Hero.getFakeZ()) * 10000;
4069
4070 break;
4071 }
4072 case HEROMOVEFLAGS:
4073 {
4074 int32_t indx = ri->d[rINDEX]/10000;
4075 if(BC::checkBounds(indx, 0, 10, "Hero->MoveFlags[]") != SH::_NoError)
4076 ret = 0; //false
4077 else
4078 {
4079 //All bits, in order, of a single byte; just use bitwise
4080 ret = (Hero.moveflags & (1<<indx)) ? 10000 : 0;
4081 }
4082 break;
4083 }
4084 case HEROLIFTFLAGS:
4085 {
4086 int32_t indx = ri->d[rINDEX]/10000;
4087 if(BC::checkBounds(indx, 0, NUM_LIFTFL-1, "Hero->LiftFlags[]") != SH::_NoError)
4088 ret = 0; //false
4089 else
4090 {
4091 ret = (Hero.liftflags & (1<<indx)) ? 10000 : 0;
4092 }
4093 break;
4094 }
4095
4096 case HEROSHIELDJINX:
4097 ret = Hero.shieldjinxclk * 10000;
4098 break;
4099
4100 case HEROISWARPING:
4101 ret = Hero.is_warping ? 10000L : 0L;
4102 break;
4103
4104 case CLOCKACTIVE:
4105 ret=watch?10000:0;
4106 break;
4107
4108 case CLOCKCLK:
4109 ret=clockclk*10000;
4110 break;
4111
4112 case HERORESPAWNX:
4113 {
4114 ret = Hero.respawn_x.getZLong();
4115 break;
4116 }
4117
4118 case HERORESPAWNY:
4119 {
4120 ret = Hero.respawn_y.getZLong();
4121 break;
4122 }
4123
4124 case HERORESPAWNDMAP:
4125 {
4126 ret = Hero.respawn_dmap * 10000;
4127 break;
4128 }
4129
4130 case HERORESPAWNSCR:
4131 {
4132 ret = Hero.respawn_scr * 10000;
4133 break;
4134 }
4135
4136 case HEROSWITCHTIMER:
4137 {
4138 ret = Hero.switchhookclk * 10000;
4139 break;
4140 }
4141
4142 case HEROSWITCHMAXTIMER:
4143 {
4144 ret = Hero.switchhookmaxtime * 10000;
4145 break;
4146 }
4147
4148 case HEROIMMORTAL:
4149 {
4150 ret = Hero.immortal * 10000;
4151 break;
4152 }
4153
4154 case HEROSTANDING:
4155 {
4156 ret = Hero.isStanding(true) ? 10000 : 0;
4157 break;
4158 }
4159
4160 case HEROCOYOTETIME:
4161 {
4162 ret = Hero.coyotetime*10000;
4163 break;
4164 }
4165
4166 case HEROLIFTEDWPN:
4167 {
4168 ret = Hero.lift_wpn ? Hero.lift_wpn->getUID() : 0;
4169 break;
4170 }
4171 case HEROLIFTTIMER:
4172 {
4173 ret = Hero.liftclk * 10000;
4174 break;
4175 }
4176 case HEROLIFTMAXTIMER:
4177 {
4178 ret = Hero.tliftclk * 10000;
4179 break;
4180 }
4181 case HEROLIFTHEIGHT:
4182 {
4183 ret = Hero.liftheight.getZLong();
4184 break;
4185 }
4186 case HEROHAMMERSTATE:
4187 {
4188 ret = Hero.getHammerState() * 10000;
4189 break;
4190 }
4191
4192 ///----------------------------------------------------------------------------------------------------//
4193 //Input States
4194 case INPUTSTART:
4195 92884 ret=control_state[6]?10000:0;
4196 92884 break;
4197
4198 case INPUTMAP:
4199 4123 ret=control_state[9]?10000:0;
4200 4123 break;
4201
4202 case INPUTUP:
4203 1334115 ret=control_state[0]?10000:0;
4204 1334115 break;
4205
4206 case INPUTDOWN:
4207 847431 ret=control_state[1]?10000:0;
4208 847431 break;
4209
4210 case INPUTLEFT:
4211 1327379 ret=control_state[2]?10000:0;
4212 1327379 break;
4213
4214 case INPUTRIGHT:
4215 1369597 ret=control_state[3]?10000:0;
4216 1369597 break;
4217
4218 case INPUTA:
4219 5693944 ret=control_state[4]?10000:0;
4220 5693944 break;
4221
4222 case INPUTB:
4223 5182994 ret=control_state[5]?10000:0;
4224 5182994 break;
4225
4226 case INPUTL:
4227 3135646 ret=control_state[7]?10000:0;
4228 3135646 break;
4229
4230 case INPUTR:
4231 3131387 ret=control_state[8]?10000:0;
4232 3131387 break;
4233
4234 case INPUTEX1:
4235 119289 ret=control_state[10]?10000:0;
4236 119289 break;
4237
4238 case INPUTEX2:
4239 119580 ret=control_state[11]?10000:0;
4240 119580 break;
4241
4242 case INPUTEX3:
4243 23391 ret=control_state[12]?10000:0;
4244 23391 break;
4245
4246 case INPUTEX4:
4247 23391 ret=control_state[13]?10000:0;
4248 23391 break;
4249
4250 case INPUTAXISUP:
4251 ret=control_state[14]?10000:0;
4252 break;
4253
4254 case INPUTAXISDOWN:
4255 ret=control_state[15]?10000:0;
4256 break;
4257
4258 case INPUTAXISLEFT:
4259 ret=control_state[16]?10000:0;
4260 break;
4261
4262 case INPUTAXISRIGHT:
4263 ret=control_state[17]?10000:0;
4264 break;
4265
4266 case INPUTMOUSEX:
4267 {
4268 766680 ret=get_mouse_state(0)*10000;
4269 766680 break;
4270 }
4271
4272 case INPUTMOUSEY:
4273 {
4274 766680 int32_t mousequakeoffset = 56+((int32_t)(zc::math::Sin((double)(quakeclk*int64_t(2)-frame))*4));
4275
3/4
✓ Branch 0 taken 17451 times.
✓ Branch 1 taken 749229 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 749229 times.
766680 int32_t tempoffset = (quakeclk > 0) ? mousequakeoffset : (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
4276 766680 ret=((get_mouse_state(1)-tempoffset))*10000;
4277 766680 break;
4278 }
4279
4280 case INPUTMOUSEZ:
4281 ret=(get_mouse_state(2))*10000;
4282 break;
4283
4284 case INPUTMOUSEB:
4285 1041016 ret=(get_mouse_state(3))*10000;
4286 1041016 break;
4287
4288 case INPUTPRESSSTART:
4289 728101 ret=button_press[6]?10000:0;
4290 728101 break;
4291
4292 case INPUTPRESSMAP:
4293 276546 ret=button_press[9]?10000:0;
4294 276546 break;
4295
4296 case INPUTPRESSUP:
4297 775420 ret=button_press[0]?10000:0;
4298 775420 break;
4299
4300 case INPUTPRESSDOWN:
4301 715403 ret=button_press[1]?10000:0;
4302 715403 break;
4303
4304 case INPUTPRESSLEFT:
4305 556980 ret=button_press[2]?10000:0;
4306 556980 break;
4307
4308 case INPUTPRESSRIGHT:
4309 514803 ret=button_press[3]?10000:0;
4310 514803 break;
4311
4312 case INPUTPRESSA:
4313 1875584 ret=button_press[4]?10000:0;
4314 1875584 break;
4315
4316 case INPUTPRESSB:
4317 1726419 ret=button_press[5]?10000:0;
4318 1726419 break;
4319
4320 case INPUTPRESSL:
4321 1861217 ret=button_press[7]?10000:0;
4322 1861217 break;
4323
4324 case INPUTPRESSR:
4325 1691656 ret=button_press[8]?10000:0;
4326 1691656 break;
4327
4328 case INPUTPRESSEX1:
4329 873882 ret=button_press[10]?10000:0;
4330 873882 break;
4331
4332 case INPUTPRESSEX2:
4333 873847 ret=button_press[11]?10000:0;
4334 873847 break;
4335
4336 case INPUTPRESSEX3:
4337 541201 ret=button_press[12]?10000:0;
4338 541201 break;
4339
4340 case INPUTPRESSEX4:
4341 541201 ret=button_press[13]?10000:0;
4342 541201 break;
4343
4344 case INPUTPRESSAXISUP:
4345 ret=button_press[14]?10000:0;
4346 break;
4347
4348 case INPUTPRESSAXISDOWN:
4349 ret=button_press[15]?10000:0;
4350 break;
4351
4352 case INPUTPRESSAXISLEFT:
4353 ret=button_press[16]?10000:0;
4354 break;
4355
4356 case INPUTPRESSAXISRIGHT:
4357 ret=button_press[17]?10000:0;
4358 break;
4359
4360 case FFRULE:
4361 {
4362 int32_t ruleid = vbound((ri->d[rINDEX]/10000),0,qr_MAX);
4363 ret = get_qr(ruleid)?10000:0;
4364 }
4365 break;
4366
4367 case BUTTONPRESS:
4368 // DUkey, DDkey, DLkey, DRkey, Akey, Bkey, Skey, Lkey, Rkey, Pkey, Exkey1, Exkey2, Exkey3, Exkey4 };
4369 {
4370 //Read-only
4371 int32_t button = vbound((ri->d[rINDEX]/10000),0,17);
4372 ret = button_press[button]?10000:0;
4373 }
4374 break;
4375
4376 case BUTTONINPUT:
4377 {
4378 //Read-only
4379 int32_t button = vbound((ri->d[rINDEX]/10000),0,17);
4380 ret=control_state[button]?10000:0;
4381 }
4382 break;
4383
4384 case BUTTONHELD:
4385 {
4386 //Read-only
4387 int32_t button = vbound((ri->d[rINDEX]/10000),0,17);
4388 ret = button_hold[button]?10000:0;
4389 }
4390 break;
4391
4392 case RAWKEY:
4393 { //Game->KeyPressed[], read-only
4394 //if ( !keypressed() ) break; //Don;t return values set by setting Hero->Input/Press
4395 //hmm...no, this won;t return properly for modifier keys.
4396 int32_t keyid = ri->d[rINDEX]/10000;
4397 //key = vbound(key,0,n);
4398 bool pressed = key_current_frame[keyid] != 0;
4399 ret = pressed?10000:0;
4400 }
4401 break;
4402
4403 case KEYINPUT:
4404 {
4405 1121 ret = KeyInput[ri->d[rINDEX]/10000] ? 10000 : 0;
4406 1121 break;
4407 }
4408 case KEYPRESS:
4409 {
4410 6213 ret = KeyPress[ri->d[rINDEX]/10000] ? 10000 : 0;
4411 6213 break;
4412 }
4413
4414 case KEYMODIFIERS:
4415 {
4416 ret = (key_shifts*10000);
4417 break;
4418 }
4419
4420 case KEYBINDINGS:
4421 {
4422 int32_t keyid = ri->d[rINDEX]/10000;
4423 switch(keyid)
4424 {
4425 case 0: ret = DUkey * 10000; break;
4426 case 1: ret = DDkey * 10000; break;
4427 case 2: ret = DLkey * 10000; break;
4428 case 3: ret = DRkey * 10000; break;
4429 case 4: ret = Akey * 10000; break;
4430 case 5: ret = Bkey * 10000; break;
4431 case 6: ret = Skey * 10000; break;
4432 case 7: ret = Lkey * 10000; break;
4433 case 8: ret = Rkey * 10000; break;
4434 case 9: ret = Pkey * 10000; /*map*/ break;
4435 case 10: ret = Exkey1 * 10000; break;
4436 case 11: ret = Exkey2 * 10000; break;
4437 case 12: ret = Exkey3 * 10000; break;
4438 case 13: ret = Exkey4 * 10000; break;
4439
4440 default: { Z_scripterrlog("Invalid index [%d] passed to Input->KeyBindings[]\n", keyid); ret = 0; break; }
4441 }
4442 break;
4443 }
4444
4445 case READKEY:
4446 {
4447 //Game->ReadKey(int32_t key), also clears it.
4448 int32_t keyid = ri->d[rINDEX]/10000;
4449 bool pressed = zc_readkey(keyid, true);
4450 ret = pressed?10000:0;
4451 }
4452 break;
4453
4454 case DISABLEKEY:
4455 {
4456 //Input->DisableKey(int32_t key)
4457 int32_t keyid = ri->d[rINDEX]/10000;
4458 ret = disabledKeys[keyid]?10000:0;
4459 break;
4460 }
4461
4462 case DISABLEBUTTON:
4463 {
4464 //Input->DisableButton(int32_t cb)
4465 int32_t cbid = ri->d[rINDEX]/10000;
4466 ret = disable_control[cbid]?10000:0;
4467 break;
4468 }
4469
4470 case JOYPADPRESS:
4471 {
4472 //Checks if a press is from the joypad, not keyboard.
4473 int32_t button = ri->d[rINDEX]/10000;
4474 ret = joybtn(button)?10000:0;
4475 }
4476 break;
4477
4478
4479 case MOUSEARR:
4480 {
4481 468 int32_t indx = (ri->d[rINDEX]/10000);
4482 int32_t rv;
4483
2/7
✗ Branch 0 not taken.
✓ Branch 1 taken 234 times.
✓ Branch 2 taken 234 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
468 switch (indx)
4484 {
4485 case 0: //MouseX
4486 {
4487 234 rv=get_mouse_state(0)*10000;
4488 234 break;
4489 }
4490 case 1: //MouseY
4491 {
4492 234 int32_t mousequakeoffset = 56+((int32_t)(zc::math::Sin((double)(quakeclk*int64_t(2)-frame))*4));
4493
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 234 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 234 times.
234 int32_t tempoffset = (quakeclk > 0) ? mousequakeoffset : (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
4494 234 int32_t topOffset= (112-tempoffset);
4495 234 rv=(get_mouse_state(1)-topOffset)*10000;
4496 234 break;
4497 }
4498 case 2: //MouseZ
4499 {
4500 rv=(get_mouse_state(2))*10000;
4501 break;
4502 }
4503 case 3: //Left Click
4504 {
4505 rv=((get_mouse_state(3)&0x1))*10000;
4506 break;
4507 }
4508 case 4: //Right Click
4509 {
4510 rv=((get_mouse_state(3)&0x2))*10000;
4511 break;
4512 }
4513 case 5: //Middle Click
4514 {
4515 rv=((get_mouse_state(3)&0x4))*10000;
4516 break;
4517 }
4518 default:
4519 {
4520 Z_scripterrlog("Invalid index passed to Input->Mouse[]: %d\n", indx);
4521 rv = -10000;
4522 break;
4523 }
4524 }
4525
4526 //bool pressed = key[keyid] != 0;
4527 //ret = pressed?10000:0;
4528 468 ret = rv;
4529 }
4530 468 break;
4531
4532 ///----------------------------------------------------------------------------------------------------//
4533 //Item Variables
4534 case ITEMSCALE:
4535 if ( get_qr(qr_OLDSPRITEDRAWS) )
4536 {
4537 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
4538 "item->Scale");
4539 ret = -1; break;
4540 }
4541 if(0!=(s=checkItem(ri->itemref)))
4542 {
4543 ret=((int32_t)((item*)(s))->scale)*100.0;
4544 }
4545 break;
4546
4547 case ITEMX:
4548
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5848 times.
5848 if(0!=(s=checkItem(ri->itemref)))
4549 {
4550
2/2
✓ Branch 0 taken 2722 times.
✓ Branch 1 taken 3126 times.
5848 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
4551 {
4552 2722 ret=(((item*)(s))->x).getZLong();
4553 2722 }
4554 3126 else ret=((int32_t)((item*)(s))->x)*10000;
4555 5848 }
4556 5848 break;
4557
4558 case ITEMSPRITESCRIPT:
4559 if(0!=(s=checkItem(ri->itemref)))
4560 {
4561 ret=((int32_t)((item*)(s))->script)*10000;
4562 }
4563 break;
4564
4565 case ITEMSPRITEINITD:
4566
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(0!=(s=checkItem(ri->itemref)))
4567 {
4568 24 int32_t a = vbound(ri->d[rINDEX]/10000,0,7);
4569 24 ret=((int32_t)((item*)(s))->initD[a]);
4570 24 }
4571 24 break;
4572
4573 case ITEMFAMILY:
4574 if(0!=(s=checkItem(ri->itemref)))
4575 {
4576 ret=((int32_t)((item*)(s))->family)*10000;
4577 }
4578 break;
4579
4580 case ITEMLEVEL:
4581 if(0!=(s=checkItem(ri->itemref)))
4582 {
4583 ret=((int32_t)((item*)(s))->lvl)*10000;
4584 }
4585 break;
4586
4587 case SPRITEMAXITEM:
4588 {
4589 //No bounds check, as this is a universal function and works from NULL pointers!
4590 ret = items.getMax() * 10000;
4591 break;
4592 }
4593
4594 case ITEMSCRIPTUID:
4595 if(0!=(s=checkItem(ri->itemref)))
4596 {
4597 ret=((int32_t)((item*)(s))->script_UID); //Literal, not *10000
4598 }
4599 break;
4600
4601 case ITEMY:
4602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4206 times.
4206 if(0!=(s=checkItem(ri->itemref)))
4603 {
4604
2/2
✓ Branch 0 taken 1080 times.
✓ Branch 1 taken 3126 times.
4206 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
4605 {
4606 1080 ret=(((item*)(s))->y).getZLong();
4607 1080 }
4608 else
4609 3126 ret=((int32_t)((item*)(s))->y)*10000;
4610 4206 }
4611 4206 break;
4612
4613 case ITEMZ:
4614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5084 times.
5084 if(0!=(s=checkItem(ri->itemref)))
4615 {
4616
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 5082 times.
5084 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
4617 {
4618 2 ret=(((item*)(s))->z).getZLong();
4619 2 }
4620 else
4621 5082 ret=((int32_t)((item*)(s))->z)*10000;
4622 5084 }
4623 5084 break;
4624
4625 case ITEMJUMP:
4626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(0!=(s=checkItem(ri->itemref)))
4627 {
4628 114 ret = ((item*)(s))->fall.getZLong() / -100;
4629
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if (get_qr(qr_SPRITE_JUMP_IS_TRUNCATED)) ret = trunc(ret / 10000) * 10000;
4630 114 }
4631 114 break;
4632
4633 case ITEMFAKEJUMP:
4634 if(0!=(s=checkItem(ri->itemref)))
4635 {
4636 ret = ((item*)(s))->fakefall.getZLong() / -100;
4637 if (get_qr(qr_SPRITE_JUMP_IS_TRUNCATED)) ret = trunc(ret / 10000) * 10000;
4638 }
4639 break;
4640
4641 case ITEMDRAWTYPE:
4642 if(0!=(s=checkItem(ri->itemref)))
4643 {
4644 ret=((item*)(s))->drawstyle*10000;
4645 }
4646 break;
4647
4648 case ITEMGRAVITY:
4649 if(0!=(s=checkItem(ri->itemref)))
4650 {
4651 ret=((((item*)(s))->moveflags & FLAG_OBEYS_GRAV) ? 10000 : 0);
4652 }
4653 break;
4654
4655 case ITEMID:
4656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 117090 times.
117090 if(0!=(s=checkItem(ri->itemref)))
4657 {
4658 117090 ret=((item*)(s))->id*10000;
4659 117090 }
4660 117090 break;
4661
4662 case ITEMTILE:
4663
1/2
✓ Branch 0 taken 7933 times.
✗ Branch 1 not taken.
7933 if(0!=(s=checkItem(ri->itemref)))
4664 {
4665 7933 ret=((item*)(s))->tile*10000;
4666 7933 }
4667 7933 break;
4668
4669 case ITEMSCRIPTTILE:
4670 if(0!=(s=checkItem(ri->itemref)))
4671 {
4672 ret=((item*)(s))->scripttile*10000;
4673 }
4674 break;
4675
4676 case ITEMSCRIPTFLIP:
4677 if(0!=(s=checkItem(ri->itemref)))
4678 {
4679 ret=((item*)(s))->scriptflip*10000;
4680 }
4681 break;
4682
4683 case ITEMPSTRING:
4684 if(0!=(s=checkItem(ri->itemref)))
4685 {
4686 ret=((item*)(s))->pstring*10000;
4687 }
4688 break;
4689 case ITEMPSTRINGFLAGS:
4690 if(0!=(s=checkItem(ri->itemref)))
4691 {
4692 ret=((item*)(s))->pickup_string_flags*10000;
4693 }
4694 break;
4695 case ITEMOVERRIDEFLAGS:
4696 ret=0;
4697 break;
4698
4699 case ITEMOTILE:
4700
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(0!=(s=checkItem(ri->itemref)))
4701 {
4702 18 ret=((item*)(s))->o_tile*10000;
4703 18 }
4704 18 break;
4705
4706 case ITEMCSET:
4707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7933 times.
7933 if(0!=(s=checkItem(ri->itemref)))
4708 {
4709 7933 ret=(((item*)(s))->o_cset&15)*10000;
4710 7933 }
4711 7933 break;
4712
4713 case ITEMFLASHCSET:
4714 if(0!=(s=checkItem(ri->itemref)))
4715 {
4716 ret=(((item*)(s))->o_cset>>4)*10000;
4717 }
4718 break;
4719
4720 case ITEMFRAMES:
4721 if(0!=(s=checkItem(ri->itemref)))
4722 {
4723 ret=((item*)(s))->frames*10000;
4724 }
4725 break;
4726
4727 case ITEMFRAME:
4728 if(0!=(s=checkItem(ri->itemref)))
4729 {
4730 ret=((item*)(s))->aframe*10000;
4731 }
4732 break;
4733
4734 case ITEMACLK:
4735 if(0!=(s=checkItem(ri->itemref)))
4736 {
4737 ret=((item*)(s))->aclk*10000;
4738 }
4739 break;
4740
4741 case ITEMASPEED:
4742 if(0!=(s=checkItem(ri->itemref)))
4743 {
4744 ret=((item*)(s))->o_speed*10000;
4745 }
4746 break;
4747
4748 case ITEMDELAY:
4749 if(0!=(s=checkItem(ri->itemref)))
4750 {
4751 ret=((item*)(s))->o_delay*10000;
4752 }
4753 break;
4754
4755 case ITEMFLIP:
4756 if(0!=(s=checkItem(ri->itemref)))
4757 {
4758 ret=((item*)(s))->flip*10000;
4759 }
4760 break;
4761
4762 case ITEMFLASH:
4763 if(0!=(s=checkItem(ri->itemref)))
4764 {
4765 ret=((item*)(s))->flash*10000;
4766 }
4767 break;
4768
4769 case ITEMHXOFS:
4770
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2552 times.
2552 if(0!=(s=checkItem(ri->itemref)))
4771 {
4772 2552 ret=(((item*)(s))->hxofs)*10000;
4773 2552 }
4774 2552 break;
4775
4776 case ITEMROTATION:
4777 if ( get_qr(qr_OLDSPRITEDRAWS) )
4778 {
4779 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
4780 "item->Rotation");
4781 ret = -1; break;
4782 }
4783 if(0!=(s=checkItem(ri->itemref)))
4784 {
4785 ret=(((item*)(s))->rotation)*10000;
4786 }
4787 break;
4788
4789 case ITEMHYOFS:
4790
1/2
✓ Branch 0 taken 2552 times.
✗ Branch 1 not taken.
2552 if(0!=(s=checkItem(ri->itemref)))
4791 {
4792 2552 ret=(((item*)(s))->hyofs)*10000;
4793 2552 }
4794 2552 break;
4795
4796 case ITEMXOFS:
4797
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(0!=(s=checkItem(ri->itemref)))
4798 {
4799 6 ret=((int32_t)(((item*)(s))->xofs))*10000;
4800 6 }
4801 6 break;
4802
4803 case ITEMYOFS:
4804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 334 times.
334 if(0!=(s=checkItem(ri->itemref)))
4805 {
4806
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 334 times.
334 ret=((int32_t)(((item*)(s))->yofs-(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)))*10000;
4807 334 }
4808 334 break;
4809
4810 case ITEMSHADOWXOFS:
4811 if(0!=(s=checkItem(ri->itemref)))
4812 {
4813 ret=((int32_t)(((item*)(s))->shadowyofs))*10000;
4814 }
4815 break;
4816
4817 case ITEMSHADOWYOFS:
4818 if(0!=(s=checkItem(ri->itemref)))
4819 {
4820 ret=((int32_t)(((item*)(s))->shadowxofs))*10000;
4821 }
4822 break;
4823
4824
4825 case ITEMZOFS:
4826 if(0!=(s=checkItem(ri->itemref)))
4827 {
4828 ret=((int32_t)(((item*)(s))->zofs))*10000;
4829 }
4830 break;
4831
4832 case ITEMHXSZ:
4833
1/2
✓ Branch 0 taken 2552 times.
✗ Branch 1 not taken.
2552 if(0!=(s=checkItem(ri->itemref)))
4834 {
4835 2552 ret=(((item*)(s))->hit_width)*10000;
4836 2552 }
4837 2552 break;
4838
4839 case ITEMHYSZ:
4840
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2552 times.
2552 if(0!=(s=checkItem(ri->itemref)))
4841 {
4842 2552 ret=(((item*)(s))->hit_height)*10000;
4843 2552 }
4844 2552 break;
4845
4846 case ITEMHZSZ:
4847
1/2
✓ Branch 0 taken 2542 times.
✗ Branch 1 not taken.
2542 if(0!=(s=checkItem(ri->itemref)))
4848 {
4849 2542 ret=(((item*)(s))->hzsz)*10000;
4850 2542 }
4851 2542 break;
4852
4853 case ITEMTXSZ:
4854
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1300 times.
1300 if(0!=(s=checkItem(ri->itemref)))
4855 {
4856 1300 ret=(((item*)(s))->txsz)*10000;
4857 1300 }
4858 1300 break;
4859
4860 case ITEMTYSZ:
4861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1300 times.
1300 if(0!=(s=checkItem(ri->itemref)))
4862 {
4863 1300 ret=(((item*)(s))->tysz)*10000;
4864 1300 }
4865 1300 break;
4866
4867 case ITEMCOUNT:
4868 685905 ret=(items.Count())*10000;
4869 685905 break;
4870
4871 case GETRENDERTARGET:
4872 ret=(zscriptDrawingRenderTarget->GetCurrentRenderTarget())*10000;
4873 break;
4874
4875 case ITEMEXTEND:
4876 if(0!=(s=checkItem(ri->itemref)))
4877 {
4878 ret=((item*)(s))->extend*10000;
4879 }
4880 break;
4881
4882 case ITEMPICKUP:
4883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19906 times.
19906 if(0!=(s=checkItem(ri->itemref)))
4884 {
4885 19906 ret=((item*)(s))->pickup*10000;
4886 19906 }
4887 19906 break;
4888
4889 case ITEMMISCD:
4890
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108294 times.
108294 if(0!=(s=checkItem(ri->itemref)))
4891 {
4892 108294 int32_t a = vbound(ri->d[rINDEX]/10000,0,31);
4893 108294 ret=(((item*)(s))->miscellaneous[a]);
4894 108294 }
4895 108294 break;
4896
4897 case ITEMFALLCLK:
4898 if(0!=(s=checkItem(ri->itemref)))
4899 {
4900 ret = ((item*)(s))->fallclk * 10000;
4901 }
4902 break;
4903
4904 case ITEMFALLCMB:
4905 if(0!=(s=checkItem(ri->itemref)))
4906 {
4907 ret = ((item*)(s))->fallCombo * 10000;
4908 }
4909 break;
4910
4911 case ITEMDROWNCLK:
4912 if(0!=(s=checkItem(ri->itemref)))
4913 {
4914 ret = ((item*)(s))->drownclk * 10000;
4915 }
4916 break;
4917
4918 case ITEMDROWNCMB:
4919 if(0!=(s=checkItem(ri->itemref)))
4920 {
4921 ret = ((item*)(s))->drownCombo * 10000;
4922 }
4923 break;
4924
4925 case ITEMFAKEZ:
4926 if(0!=(s=checkItem(ri->itemref)))
4927 {
4928 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
4929 {
4930 ret=(((item*)(s))->fakez).getZLong();
4931 }
4932 else
4933 ret=((int32_t)((item*)(s))->fakez)*10000;
4934 }
4935 break;
4936
4937
4938 case ITEMMOVEFLAGS:
4939 {
4940 if(0!=(s=checkItem(ri->itemref)))
4941 {
4942 int32_t indx = ri->d[rINDEX]/10000;
4943 if(BC::checkBounds(indx, 0, 10, "itemsprite->MoveFlags[]") != SH::_NoError)
4944 ret = 0; //false
4945 else
4946 {
4947 //All bits, in order, of a single byte; just use bitwise
4948 ret = (((item*)(s))->moveflags & (1<<indx)) ? 10000 : 0;
4949 }
4950 }
4951 break;
4952 }
4953
4954 case ITEMGLOWRAD:
4955 if(0!=(s=checkItem(ri->itemref)))
4956 {
4957 ret = ((item*)(s))->glowRad * 10000;
4958 }
4959 break;
4960
4961 case ITEMGLOWSHP:
4962 if(0!=(s=checkItem(ri->itemref)))
4963 {
4964 ret = ((item*)(s))->glowShape * 10000;
4965 }
4966 break;
4967
4968 case ITEMDIR:
4969 if(0!=(s=checkItem(ri->itemref)))
4970 {
4971 ret = ((item*)(s))->dir * 10000;
4972 }
4973 break;
4974
4975 case ITEMENGINEANIMATE:
4976 if(0!=(s=checkItem(ri->itemref)))
4977 {
4978 ret = int32_t(((item*)(s))->do_animation) * 10000;
4979 }
4980 break;
4981
4982 case ITEMSHADOWSPR:
4983 if(0!=(s=checkItem(ri->itemref)))
4984 {
4985 ret = int32_t(((item*)(s))->spr_shadow) * 10000;
4986 }
4987 break;
4988 case ITEMDROPPEDBY:
4989 if(0!=(s=checkItem(ri->itemref)))
4990 {
4991 ret = int32_t(((item*)(s))->from_dropset) * 10000;
4992 }
4993 break;
4994 case ITMSWHOOKED:
4995 if(0!=(s=checkItem(ri->itemref)))
4996 {
4997 ret = s->switch_hooked ? 10000 : 0;
4998 }
4999 break;
5000 case ITEMFORCEGRAB:
5001 if(0!=(s=checkItem(ri->itemref)))
5002 {
5003 ret = ((item*)s)->get_forcegrab() ? 10000 : 0;
5004 }
5005 break;
5006
5007 ///----------------------------------------------------------------------------------------------------//
5008 //Itemdata Variables
5009
5010
5011 case IDATAUSEWPN:
5012 if(unsigned(ri->idata) >= MAXITEMS)
5013 {
5014 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5015 ret = -10000;
5016 break;
5017 }
5018 ret=(itemsbuf[ri->idata].useweapon)*10000;
5019 break;
5020 case IDATAUSEDEF:
5021 if(unsigned(ri->idata) >= MAXITEMS)
5022 {
5023 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5024 ret = -10000;
5025 break;
5026 }
5027 ret=(itemsbuf[ri->idata].usedefence)*10000;
5028 break;
5029 case IDATAWRANGE:
5030 if(unsigned(ri->idata) >= MAXITEMS)
5031 {
5032 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5033 ret = -10000;
5034 break;
5035 }
5036 ret=(itemsbuf[ri->idata].weaprange)*10000;
5037 break;
5038 case IDATAMAGICTIMER:
5039 if(unsigned(ri->idata) >= MAXITEMS)
5040 {
5041 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5042 ret = -10000;
5043 break;
5044 }
5045 ret=(itemsbuf[ri->idata].magiccosttimer[0])*10000;
5046 break;
5047 case IDATAMAGICTIMER2:
5048 if(unsigned(ri->idata) >= MAXITEMS)
5049 {
5050 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5051 ret = -10000;
5052 break;
5053 }
5054 ret=(itemsbuf[ri->idata].magiccosttimer[1])*10000;
5055 break;
5056 case IDATAUSEMVT:
5057 {
5058 if(unsigned(ri->idata) >= MAXITEMS)
5059 {
5060 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5061 ret = -10000;
5062 break;
5063 }
5064 int32_t a = vbound((ri->d[rINDEX] / 10000),0,(ITEM_MOVEMENT_PATTERNS-1));
5065 ret=(itemsbuf[ri->idata].weap_pattern[a])*10000;
5066 }
5067 break;
5068
5069 case IDATADURATION:
5070 if(unsigned(ri->idata) >= MAXITEMS)
5071 {
5072 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5073 ret = -10000;
5074 break;
5075 }
5076 ret=(itemsbuf[ri->idata].weapduration)*10000;
5077 break;
5078
5079 case IDATADUPLICATES:
5080 if(unsigned(ri->idata) >= MAXITEMS)
5081 {
5082 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5083 ret = -10000;
5084 break;
5085 }
5086 ret=(itemsbuf[ri->idata].duplicates)*10000;
5087 break;
5088 case IDATADRAWLAYER:
5089 if(unsigned(ri->idata) >= MAXITEMS)
5090 {
5091 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5092 ret = -10000;
5093 break;
5094 }
5095 ret=(itemsbuf[ri->idata].drawlayer)*10000;
5096 break;
5097 case IDATACOLLECTFLAGS:
5098 if(unsigned(ri->idata) >= MAXITEMS)
5099 {
5100 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5101 ret = 0;
5102 break;
5103 }
5104 ret=(itemsbuf[ri->idata].collectflags)*10000;
5105 break;
5106 case IDATAWEAPONSCRIPT:
5107 if(unsigned(ri->idata) >= MAXITEMS)
5108 {
5109 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5110 ret = -10000;
5111 break;
5112 }
5113 ret=(itemsbuf[ri->idata].weaponscript)*10000;
5114 break;
5115 case IDATAMISCD:
5116 {
5117 if(unsigned(ri->idata) >= MAXITEMS)
5118 {
5119 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5120 ret = -10000;
5121 break;
5122 }
5123 int32_t a = vbound((ri->d[rINDEX] / 10000),0,31);
5124 ret=(itemsbuf[ri->idata].wpn_misc_d[a])*10000;
5125 }
5126 break;
5127 case IDATAWPNINITD:
5128 {
5129 if(unsigned(ri->idata) >= MAXITEMS)
5130 {
5131 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5132 ret = -10000;
5133 break;
5134 }
5135 int32_t a = vbound((ri->d[rINDEX] / 10000),0,7);
5136 ret=(itemsbuf[ri->idata].weap_initiald[a]);
5137 }
5138 break;
5139 case IDATAWEAPHXOFS:
5140 if(unsigned(ri->idata) >= MAXITEMS)
5141 {
5142 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5143 ret = -10000;
5144 break;
5145 }
5146 ret=(itemsbuf[ri->idata].weap_hxofs)*10000;
5147 break;
5148 case IDATAWEAPHYOFS:
5149 if(unsigned(ri->idata) >= MAXITEMS)
5150 {
5151 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5152 ret = -10000;
5153 break;
5154 }
5155 ret=(itemsbuf[ri->idata].weap_hyofs)*10000;
5156 break;
5157 case IDATAWEAPHXSZ:
5158 if(unsigned(ri->idata) >= MAXITEMS)
5159 {
5160 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5161 ret = -10000;
5162 break;
5163 }
5164 ret=(itemsbuf[ri->idata].weap_hxsz)*10000;
5165 break;
5166 case IDATAWEAPHYSZ:
5167 if(unsigned(ri->idata) >= MAXITEMS)
5168 {
5169 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5170 ret = -10000;
5171 break;
5172 }
5173 ret=(itemsbuf[ri->idata].weap_hysz)*10000;
5174 break;
5175 case IDATAWEAPHZSZ:
5176 if(unsigned(ri->idata) >= MAXITEMS)
5177 {
5178 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5179 ret = -10000;
5180 break;
5181 }
5182 ret=(itemsbuf[ri->idata].weap_hzsz)*10000;
5183 break;
5184 case IDATAWEAPXOFS:
5185 if(unsigned(ri->idata) >= MAXITEMS)
5186 {
5187 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5188 ret = -10000;
5189 break;
5190 }
5191 ret=(itemsbuf[ri->idata].weap_xofs)*10000;
5192 break;
5193 case IDATAWEAPYOFS:
5194 if(unsigned(ri->idata) >= MAXITEMS)
5195 {
5196 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5197 ret = -10000;
5198 break;
5199 }
5200 ret=(itemsbuf[ri->idata].weap_yofs)*10000;
5201 break;
5202 case IDATAHXOFS:
5203 if(unsigned(ri->idata) >= MAXITEMS)
5204 {
5205 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5206 ret = -10000;
5207 break;
5208 }
5209 ret=(itemsbuf[ri->idata].hxofs)*10000;
5210 break;
5211 case IDATAHYOFS:
5212 if(unsigned(ri->idata) >= MAXITEMS)
5213 {
5214 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5215 ret = -10000;
5216 break;
5217 }
5218 ret=(itemsbuf[ri->idata].hyofs)*10000;
5219 break;
5220 case IDATAHXSZ:
5221 if(unsigned(ri->idata) >= MAXITEMS)
5222 {
5223 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5224 ret = -10000;
5225 break;
5226 }
5227 ret=(itemsbuf[ri->idata].hxsz)*10000;
5228 break;
5229 case IDATAHYSZ:
5230 if(unsigned(ri->idata) >= MAXITEMS)
5231 {
5232 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5233 ret = -10000;
5234 break;
5235 }
5236 ret=(itemsbuf[ri->idata].hysz)*10000;
5237 break;
5238 case IDATAHZSZ:
5239 if(unsigned(ri->idata) >= MAXITEMS)
5240 {
5241 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5242 ret = -10000;
5243 break;
5244 }
5245 ret=(itemsbuf[ri->idata].hzsz)*10000;
5246 break;
5247 case IDATADXOFS:
5248 if(unsigned(ri->idata) >= MAXITEMS)
5249 {
5250 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5251 ret = -10000;
5252 break;
5253 }
5254 ret=(itemsbuf[ri->idata].xofs)*10000;
5255 break;
5256 case IDATADYOFS:
5257 if(unsigned(ri->idata) >= MAXITEMS)
5258 {
5259 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5260 ret = -10000;
5261 break;
5262 }
5263 ret=(itemsbuf[ri->idata].yofs)*10000;
5264 break;
5265 case IDATATILEW:
5266 if(unsigned(ri->idata) >= MAXITEMS)
5267 {
5268 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5269 ret = -10000;
5270 break;
5271 }
5272 ret=(itemsbuf[ri->idata].tilew)*10000;
5273 break;
5274 case IDATATILEH:
5275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if(unsigned(ri->idata) >= MAXITEMS)
5276 {
5277 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5278 ret = -10000;
5279 break;
5280 }
5281 53 ret=(itemsbuf[ri->idata].tileh)*10000;
5282 53 break;
5283 case IDATAPICKUP:
5284 if(unsigned(ri->idata) >= MAXITEMS)
5285 {
5286 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5287 ret = -10000;
5288 break;
5289 }
5290 ret=(itemsbuf[ri->idata].pickup)*10000;
5291 break;
5292 case IDATAOVERRIDEFL:
5293 if(unsigned(ri->idata) >= MAXITEMS)
5294 {
5295 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5296 ret = 0;
5297 break;
5298 }
5299 ret=(itemsbuf[ri->idata].overrideFLAGS)*10000;
5300 break;
5301
5302 case IDATATILEWWEAP:
5303 if(unsigned(ri->idata) >= MAXITEMS)
5304 {
5305 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5306 ret = -10000;
5307 break;
5308 }
5309 ret=(itemsbuf[ri->idata].weap_tilew)*10000;
5310 break;
5311 case IDATATILEHWEAP:
5312 if(unsigned(ri->idata) >= MAXITEMS)
5313 {
5314 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5315 ret = -10000;
5316 break;
5317 }
5318 ret=(itemsbuf[ri->idata].weap_tileh)*10000;
5319 break;
5320 case IDATAOVERRIDEFLWEAP:
5321 if(unsigned(ri->idata) >= MAXITEMS)
5322 {
5323 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5324 ret = 0;
5325 break;
5326 }
5327 ret=(itemsbuf[ri->idata].weapoverrideFLAGS)*10000;
5328 break;
5329
5330 case IDATAFAMILY:
5331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 901 times.
901 if(unsigned(ri->idata) >= MAXITEMS)
5332 {
5333 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5334 ret = -10000;
5335 break;
5336 }
5337 901 ret=(itemsbuf[ri->idata].family)*10000;
5338 901 break;
5339
5340 case IDATALEVEL:
5341 if(unsigned(ri->idata) >= MAXITEMS)
5342 {
5343 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5344 ret = -10000;
5345 break;
5346 }
5347 ret=(itemsbuf[ri->idata].fam_type)*10000;
5348 break;
5349
5350 case IDATAKEEP:
5351 ret = item_flag(ITEM_GAMEDATA);
5352 break;
5353
5354 case IDATAAMOUNT:
5355 {
5356 if(unsigned(ri->idata) >= MAXITEMS)
5357 {
5358 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5359 ret = -10000;
5360 break;
5361 }
5362 int32_t v = itemsbuf[ri->idata].amount;
5363 ret = ((v&0x4000)?-1:1)*(v & 0x3FFF)*10000;
5364 break;
5365 }
5366 case IDATAGRADUAL:
5367 {
5368 if(unsigned(ri->idata) >= MAXITEMS)
5369 {
5370 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5371 ret = -10000;
5372 break;
5373 }
5374 ret = (itemsbuf[ri->idata].amount&0x8000) ? 10000 : 0;
5375 break;
5376 }
5377 case IDATACONSTSCRIPT:
5378 ret = item_flag(ITEM_PASSIVESCRIPT);
5379 break;
5380 case IDATASSWIMDISABLED:
5381 ret = item_flag(ITEM_SIDESWIM_DISABLED);
5382 break;
5383 case IDATABUNNYABLE:
5384 ret = item_flag(ITEM_BUNNY_ENABLED);
5385 break;
5386 case IDATAJINXIMMUNE:
5387 ret = item_flag(ITEM_JINX_IMMUNE);
5388 break;
5389 case IDATAJINXSWAP:
5390 ret = item_flag(ITEM_FLIP_JINX);
5391 break;
5392
5393 case IDATASETMAX:
5394 if(unsigned(ri->idata) >= MAXITEMS)
5395 {
5396 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5397 ret = -10000;
5398 break;
5399 }
5400 ret=(itemsbuf[ri->idata].setmax)*10000;
5401 break;
5402
5403 case IDATAMAX:
5404 if(unsigned(ri->idata) >= MAXITEMS)
5405 {
5406 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5407 ret = -10000;
5408 break;
5409 }
5410 ret=(itemsbuf[ri->idata].max)*10000;
5411 break;
5412
5413 case IDATACOUNTER:
5414 if(unsigned(ri->idata) >= MAXITEMS)
5415 {
5416 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5417 ret = -10000;
5418 break;
5419 }
5420 ret=(itemsbuf[ri->idata].count)*10000;
5421 break;
5422
5423 case IDATAPSOUND:
5424 if(unsigned(ri->idata) >= MAXITEMS)
5425 {
5426 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5427 ret = -10000;
5428 break;
5429 }
5430 ret=(itemsbuf[ri->idata].playsound)*10000;
5431 break;
5432 case IDATAUSESOUND:
5433 if(unsigned(ri->idata) >= MAXITEMS)
5434 {
5435 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5436 ret = -10000;
5437 break;
5438 }
5439 ret=(itemsbuf[ri->idata].usesound)*10000;
5440 break;
5441
5442 case IDATAUSESOUND2:
5443 if(unsigned(ri->idata) >= MAXITEMS)
5444 {
5445 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5446 ret = -10000;
5447 break;
5448 }
5449 ret=(itemsbuf[ri->idata].usesound2)*10000;
5450 break;
5451
5452 case IDATAPOWER:
5453
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(unsigned(ri->idata) >= MAXITEMS)
5454 {
5455 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5456 ret = -10000;
5457 break;
5458 }
5459 140 ret=(itemsbuf[ri->idata].power)*10000;
5460 140 break;
5461
5462 //Get the ID of an item.
5463 case IDATAID:
5464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1765 times.
1765 if(unsigned(ri->idata) >= MAXITEMS)
5465 {
5466 //Don't error here //Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5467 ret = -10000;
5468 break;
5469 }
5470 1765 ret=ri->idata*10000;
5471 1765 break;
5472
5473 //Get the script assigned to an item (active)
5474 case IDATASCRIPT:
5475 if(unsigned(ri->idata) >= MAXITEMS)
5476 {
5477 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5478 ret = -10000;
5479 break;
5480 }
5481 ret=(itemsbuf[ri->idata].script)*10000;
5482 break;
5483 case IDATASPRSCRIPT:
5484 if(unsigned(ri->idata) >= MAXITEMS)
5485 {
5486 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5487 ret = -10000;
5488 break;
5489 }
5490 ret=(itemsbuf[ri->idata].sprite_script)*10000;
5491 break;
5492 //Get the ->Attributes[] of an item
5493 case IDATAATTRIB:
5494 {
5495 if(unsigned(ri->idata) >= MAXITEMS)
5496 {
5497 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5498 ret = -10000;
5499 break;
5500 }
5501 int32_t index = vbound(ri->d[rINDEX]/10000,0,9);
5502 switch(index)
5503 {
5504 case 0:
5505 ret=(itemsbuf[ri->idata].misc1)*10000; break;
5506 case 1:
5507 ret=(itemsbuf[ri->idata].misc2)*10000; break;
5508 case 2:
5509 ret=(itemsbuf[ri->idata].misc3)*10000; break;
5510 case 3:
5511 ret=(itemsbuf[ri->idata].misc4)*10000; break;
5512 case 4:
5513 ret=(itemsbuf[ri->idata].misc5)*10000; break;
5514 case 5:
5515 ret=(itemsbuf[ri->idata].misc6)*10000; break;
5516 case 6:
5517 ret=(itemsbuf[ri->idata].misc7)*10000; break;
5518 case 7:
5519 ret=(itemsbuf[ri->idata].misc8)*10000; break;
5520 case 8:
5521 ret=(itemsbuf[ri->idata].misc9)*10000; break;
5522 case 9:
5523 ret=(itemsbuf[ri->idata].misc10)*10000; break;
5524 default:
5525 ret = -10000; break;
5526 }
5527
5528 break;
5529 }
5530 //Get the ->Sprite[] of an item.
5531 case IDATASPRITE:
5532 {
5533 if(unsigned(ri->idata) >= MAXITEMS)
5534 {
5535 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5536 ret = -10000;
5537 break;
5538 }
5539 int32_t index = vbound(ri->d[rINDEX]/10000,0,9);
5540 switch(index)
5541 {
5542 case 0:
5543 ret=(itemsbuf[ri->idata].wpn)*10000; break;
5544 case 1:
5545 ret=(itemsbuf[ri->idata].wpn2)*10000; break;
5546 case 2:
5547 ret=(itemsbuf[ri->idata].wpn3)*10000; break;
5548 case 3:
5549 ret=(itemsbuf[ri->idata].wpn4)*10000; break;
5550 case 4:
5551 ret=(itemsbuf[ri->idata].wpn5)*10000; break;
5552 case 5:
5553 ret=(itemsbuf[ri->idata].wpn6)*10000; break;
5554 case 6:
5555 ret=(itemsbuf[ri->idata].wpn7)*10000; break;
5556 case 7:
5557 ret=(itemsbuf[ri->idata].wpn8)*10000; break;
5558 case 8:
5559 ret=(itemsbuf[ri->idata].wpn9)*10000; break;
5560 case 9:
5561 ret=(itemsbuf[ri->idata].wpn10)*10000; break;
5562 default:
5563 ret = -10000; break;
5564 }
5565
5566 break;
5567 }
5568 //Hero TIle modifier
5569 case IDATALTM:
5570 if(unsigned(ri->idata) >= MAXITEMS)
5571 {
5572 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5573 ret = 0;
5574 break;
5575 }
5576 ret=(itemsbuf[ri->idata].ltm)*10000;
5577 break;
5578 //Pickup script
5579 case IDATAPSCRIPT:
5580 if(unsigned(ri->idata) >= MAXITEMS)
5581 {
5582 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5583 ret = -10000;
5584 break;
5585 }
5586 ret=(itemsbuf[ri->idata].collect_script)*10000;
5587 break;
5588 //Pickup string
5589 case IDATAPSTRING:
5590 if(unsigned(ri->idata) >= MAXITEMS)
5591 {
5592 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5593 ret = -10000;
5594 break;
5595 }
5596 ret=(itemsbuf[ri->idata].pstring)*10000;
5597 break;
5598 case IDATAPFLAGS:
5599 if(unsigned(ri->idata) >= MAXITEMS)
5600 {
5601 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5602 ret = 0;
5603 break;
5604 }
5605 ret=(itemsbuf[ri->idata].pickup_string_flags)*10000;
5606 break;
5607 //Magic cost
5608 case IDATAMAGCOST:
5609 if(unsigned(ri->idata) >= MAXITEMS)
5610 {
5611 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5612 ret = -10000;
5613 break;
5614 }
5615 ret=(itemsbuf[ri->idata].cost_amount[0])*10000;
5616 break;
5617 case IDATACOST2:
5618 if(unsigned(ri->idata) >= MAXITEMS)
5619 {
5620 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5621 ret = -10000;
5622 break;
5623 }
5624 ret=(itemsbuf[ri->idata].cost_amount[1])*10000;
5625 break;
5626 //cost counter ref
5627 case IDATACOSTCOUNTER:
5628 if(unsigned(ri->idata) >= MAXITEMS)
5629 {
5630 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5631 ret = -10000;
5632 break;
5633 }
5634 ret=(itemsbuf[ri->idata].cost_counter[0])*10000;
5635 break;
5636 case IDATACOSTCOUNTER2:
5637 if(unsigned(ri->idata) >= MAXITEMS)
5638 {
5639 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5640 ret = -10000;
5641 break;
5642 }
5643 ret=(itemsbuf[ri->idata].cost_counter[1])*10000;
5644 break;
5645 //Min Hearts to Pick Up
5646 case IDATAMINHEARTS:
5647 if(unsigned(ri->idata) >= MAXITEMS)
5648 {
5649 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5650 ret = -10000;
5651 break;
5652 }
5653 ret=(itemsbuf[ri->idata].pickup_hearts)*10000;
5654 break;
5655 //Tile used by the item
5656 case IDATATILE:
5657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50207 times.
50207 if(unsigned(ri->idata) >= MAXITEMS)
5658 {
5659 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5660 ret = -10000;
5661 break;
5662 }
5663 50207 ret=(itemsbuf[ri->idata].tile)*10000;
5664 50207 break;
5665 //itemdata->Flash
5666 case IDATAMISC:
5667 if(unsigned(ri->idata) >= MAXITEMS)
5668 {
5669 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5670 ret = -10000;
5671 break;
5672 }
5673 ret=(itemsbuf[ri->idata].misc_flags)*10000;
5674 break;
5675 //->CSet
5676 case IDATACSET:
5677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50207 times.
50207 if(unsigned(ri->idata) >= MAXITEMS)
5678 {
5679 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5680 ret = -10000;
5681 break;
5682 }
5683 50207 ret=(itemsbuf[ri->idata].csets)*10000;
5684 50207 break;
5685 //->A.Frames
5686 case IDATAFRAMES:
5687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61651 times.
61651 if(unsigned(ri->idata) >= MAXITEMS)
5688 {
5689 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5690 ret = -10000;
5691 break;
5692 }
5693 61651 ret=(itemsbuf[ri->idata].frames)*10000;
5694 61651 break;
5695 /*
5696 case IDATAFRAME:
5697 ret=(itemsbuf[ri->idata].frame)*10000;
5698 break;
5699 */
5700 //->A.Speed
5701 case IDATAASPEED:
5702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134799 times.
134799 if(unsigned(ri->idata) >= MAXITEMS)
5703 {
5704 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5705 ret = -10000;
5706 break;
5707 }
5708 134799 ret=(itemsbuf[ri->idata].speed)*10000;
5709 134799 break;
5710 //->Delay
5711 case IDATADELAY:
5712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73148 times.
73148 if(unsigned(ri->idata) >= MAXITEMS)
5713 {
5714 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5715 ret = -10000;
5716 break;
5717 }
5718 73148 ret=(itemsbuf[ri->idata].delay)*10000;
5719 73148 break;
5720 // teo of this item upgrades
5721 case IDATACOMBINE:
5722 ret = item_flag(ITEM_COMBINE);
5723 break;
5724 //Use item, and get the lower level one
5725 case IDATADOWNGRADE:
5726 ret = item_flag(ITEM_DOWNGRADE);
5727 break;
5728 //Only validate the cost, don't charge it
5729 case IDATAVALIDATE:
5730 ret = item_flag(ITEM_VALIDATEONLY);
5731 break;
5732 case IDATAVALIDATE2:
5733 ret = item_flag(ITEM_VALIDATEONLY2);
5734 break;
5735 //->Flags[5]
5736 case IDATAFLAGS:
5737 {
5738 if(unsigned(ri->idata) >= MAXITEMS)
5739 {
5740 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5741 ret = 0;
5742 break;
5743 }
5744 int32_t index = ri->d[rINDEX]/10000;
5745 switch(index)
5746 {
5747 case 0:
5748 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG1)?10000:0; break;
5749 case 1:
5750 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG2)?10000:0; break;
5751 case 2:
5752 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG3)?10000:0; break;
5753 case 3:
5754 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG4)?10000:0; break;
5755 case 4:
5756 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG5)?10000:0; break;
5757 case 5:
5758 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG6)?10000:0; break;
5759 case 6:
5760 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG7)?10000:0; break;
5761 case 7:
5762 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG8)?10000:0; break;
5763 case 8:
5764 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG9)?10000:0; break;
5765 case 9:
5766 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG10)?10000:0; break;
5767 case 10:
5768 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG11)?10000:0; break;
5769 case 11:
5770 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG12)?10000:0; break;
5771 case 12:
5772 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG13)?10000:0; break;
5773 case 13:
5774 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG14)?10000:0; break;
5775 case 14:
5776 ret=(itemsbuf[ri->idata].flags & ITEM_FLAG15)?10000:0; break;
5777 case 15:
5778 ret=(itemsbuf[ri->idata].flags & ITEM_PASSIVESCRIPT)?10000:0; break;
5779
5780
5781 default:
5782 Z_scripterrlog("Invalid itemdata->Flags[] index: %d\n", index);
5783 ret = 0;
5784 break;
5785 }
5786 break;
5787 }
5788
5789 //->Keep Old
5790 case IDATAKEEPOLD:
5791 ret = item_flag(ITEM_KEEPOLD);
5792 break;
5793 //Use rupees instead of magic
5794 case IDATARUPEECOST:
5795 ret = item_flag(ITEM_RUPEE_MAGIC);
5796 break;
5797 //Can be eaten
5798 case IDATAEDIBLE:
5799 ret = item_flag(ITEM_EDIBLE);
5800 break;
5801 //currently unused
5802 case IDATAFLAGUNUSED:
5803 ret = item_flag(ITEM_UNUSED);
5804 break;
5805 //Gain lower level items when collected
5806 case IDATAGAINLOWER:
5807 ret = item_flag(ITEM_GAINOLD);
5808 break;
5809 //Unchanged from master
5810 case IDATAINITDD:
5811 {
5812 int32_t a = ri->d[rINDEX] / 10000;
5813 if(unsigned(ri->idata) >= MAXITEMS)
5814 {
5815 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
5816 ret = -10000;
5817 break;
5818 }
5819
5820 if(BC::checkBounds(a, 0, 7, "itemdata->InitD") != SH::_NoError)
5821 ret = -10000;
5822 else
5823 ret = itemsbuf[ri->idata].initiald[a];
5824 }
5825 break;
5826
5827 ///----------------------------------------------------------------------------------------------------//
5828 //NPC Variables
5829
5830 //Reduces accessing integer members to one line
5831 #define GET_NPC_VAR_INT(member, str) \
5832 { \
5833 if(GuyH::loadNPC(ri->guyref, str) != SH::_NoError) \
5834 ret = -10000; \
5835 else \
5836 ret = GuyH::getNPC()->member * 10000; \
5837 }
5838
5839 case NPCDIR:
5840
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77690 times.
77690 if(GuyH::loadNPC(ri->guyref, "npc->Dir") != SH::_NoError)
5841 ret = -10000;
5842 else
5843
2/2
✓ Branch 0 taken 72477 times.
✓ Branch 1 taken 5213 times.
77690 ret = zc_max(GuyH::getNPC()->dir * 10000, 0);
5844
5845 77690 break;
5846
5847 case NPCHITDIR:
5848 if(GuyH::loadNPC(ri->guyref, "npc->HitDir") != SH::_NoError)
5849 ret = -10000;
5850 else
5851 ret = (GuyH::getNPC()->hitdir * 10000);
5852
5853 break;
5854
5855 case NPCSLIDECLK:
5856 if(GuyH::loadNPC(ri->guyref, "npc->SlideClock") != SH::_NoError)
5857 ret = -10000;
5858 else
5859 ret = (GuyH::getNPC()->sclk * 10000);
5860
5861 break;
5862
5863 case NPCHALTCLK:
5864 if(GuyH::loadNPC(ri->guyref, "npc->Halt") != SH::_NoError)
5865 ret = -10000;
5866 else
5867 ret = (GuyH::getNPC()->clk2 * 10000);
5868
5869 break;
5870
5871 case NPCFRAME:
5872 if(GuyH::loadNPC(ri->guyref, "npc->Frame") != SH::_NoError)
5873 ret = -10000;
5874 else
5875 ret = (GuyH::getNPC()->clk * 10000);
5876
5877 break;
5878
5879 case NPCMOVESTATUS:
5880 if(GuyH::loadNPC(ri->guyref, "npc->MoveStatus") != SH::_NoError)
5881 ret = -10000;
5882 else
5883 ret = (GuyH::getNPC()->movestatus * 10000);
5884
5885 break;
5886
5887 case NPCFADING:
5888 if(GuyH::loadNPC(ri->guyref, "npc->Fading") != SH::_NoError)
5889 ret = -10000;
5890 else
5891 ret = (GuyH::getNPC()->fading * 10000);
5892
5893 break;
5894
5895 case NPCRATE:
5896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 426414 times.
426414 GET_NPC_VAR_INT(rate, "npc->Rate") break;
5897
5898 case NPCHOMING:
5899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 436097 times.
436097 GET_NPC_VAR_INT(homing, "npc->Homing") break;
5900
5901 case NPCFRAMERATE:
5902 GET_NPC_VAR_INT(frate, "npc->ASpeed") break;
5903
5904 case NPCHALTRATE:
5905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410674 times.
410674 GET_NPC_VAR_INT(hrate, "npc->HaltRate") break;
5906
5907 case NPCRANDOM:
5908 GET_NPC_VAR_INT(rate, "npc->Random") break;
5909
5910 case NPCDRAWTYPE:
5911 GET_NPC_VAR_INT(drawstyle, "npc->DrawStyle") break;
5912
5913 case NPCHP:
5914
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 5123276 times.
5123278 GET_NPC_VAR_INT(hp, "npc->HP") break;
5915
5916 case NPCORIGINALHP:
5917 GET_NPC_VAR_INT(starting_hp, "npc->OriginalHP") break;
5918
5919 case NPCCOLLDET:
5920
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 165739 times.
165739 GET_NPC_VAR_INT(scriptcoldet, "npc->ColDetection") break;
5921
5922 case NPCENGINEANIMATE:
5923 GET_NPC_VAR_INT(do_animation, "npc->Animation") break;
5924
5925 case NPCSTUN:
5926
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1128791 times.
1128791 GET_NPC_VAR_INT(stunclk, "npc->Stun") break;
5927
5928 case NPCHUNGER:
5929
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 472577 times.
472577 GET_NPC_VAR_INT(grumble, "npc->Hunger") break;
5930
5931 case NPCWEAPSPRITE:
5932 GET_NPC_VAR_INT(wpnsprite, "npc->WeaponSprite") break;
5933
5934 case NPCTYPE:
5935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 532410 times.
532410 GET_NPC_VAR_INT(family, "npc->Type") break;
5936
5937 case NPCDP:
5938
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 3165 times.
3169 GET_NPC_VAR_INT(dp, "npc->Damage") break;
5939
5940 case NPCWDP:
5941
2/2
✓ Branch 0 taken 244 times.
✓ Branch 1 taken 12956 times.
13200 GET_NPC_VAR_INT(wdp, "npc->WeaponDamage") break;
5942
5943 case NPCOTILE:
5944
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5408 times.
5408 GET_NPC_VAR_INT(o_tile, "npc->OriginalTile") break;
5945
5946 case NPCTILE:
5947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39139 times.
39139 GET_NPC_VAR_INT(tile, "npc->Tile") break;
5948
5949 case NPCSCRIPTTILE:
5950 GET_NPC_VAR_INT(scripttile, "npc->ScriptTile") break;
5951
5952 case NPCSCRIPTFLIP:
5953 GET_NPC_VAR_INT(scriptflip, "npc->ScriptFlip") break;
5954
5955 case NPCWEAPON:
5956
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 404 times.
404 GET_NPC_VAR_INT(wpn, "npc->Weapon") break;
5957
5958 case NPCITEMSET:
5959 GET_NPC_VAR_INT(item_set, "npc->ItemSet") break;
5960
5961 case NPCCSET:
5962
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17986 times.
17986 GET_NPC_VAR_INT(cs, "npc->CSet") break;
5963
5964 case NPCBOSSPAL:
5965 GET_NPC_VAR_INT(bosspal, "npc->BossPal") break;
5966
5967 case NPCBGSFX:
5968 GET_NPC_VAR_INT(bgsfx, "npc->SFX") break;
5969
5970 case NPCEXTEND:
5971
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6086 times.
6086 GET_NPC_VAR_INT(extend, "npc->Extend") break;
5972
5973 case NPCHXOFS:
5974
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383015 times.
383015 GET_NPC_VAR_INT(hxofs, "npc->HitXOffset") break;
5975
5976 case NPCHYOFS:
5977
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383015 times.
383015 GET_NPC_VAR_INT(hyofs, "npc->HitYOffset") break;
5978
5979 case NPCHXSZ:
5980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 427914 times.
427914 GET_NPC_VAR_INT(hit_width, "npc->HitWidth") break;
5981
5982 case NPCHYSZ:
5983
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 427914 times.
427914 GET_NPC_VAR_INT(hit_height, "npc->HitHeight") break;
5984
5985 case NPCHZSZ:
5986
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226198 times.
226198 GET_NPC_VAR_INT(hzsz, "npc->HitZHeight") break;
5987
5988 case NPCROTATION:
5989 if ( get_qr(qr_OLDSPRITEDRAWS) )
5990 {
5991 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
5992 "npc->Rotation");
5993 ret = -1; break;
5994 }
5995 GET_NPC_VAR_INT(rotation, "npc->Rotation") break;
5996
5997 case NPCTXSZ:
5998
2/2
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 1503636 times.
1504060 GET_NPC_VAR_INT(txsz, "npc->TileWidth") break;
5999
6000 case NPCTYSZ:
6001
2/2
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 1485761 times.
1486185 GET_NPC_VAR_INT(tysz, "npc->TileHeight") break;
6002
6003 //And zfix
6004 #define GET_NPC_VAR_FIX(member, str) \
6005 { \
6006 if(GuyH::loadNPC(ri->guyref, str) != SH::_NoError) \
6007 { \
6008 ret = -10000; \
6009 break; \
6010 } \
6011 else \
6012 ret = (int32_t(GuyH::getNPC()->member) * 10000); \
6013 }
6014
6015 case NPCX:
6016 //GET_NPC_VAR_FIX(x, "npc->X") break;
6017 {
6018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1058431 times.
1058431 if(GuyH::loadNPC(ri->guyref, "X") != SH::_NoError)
6019 {
6020 ret = -10000;
6021 }
6022 else
6023 {
6024
2/2
✓ Branch 0 taken 11121 times.
✓ Branch 1 taken 1047310 times.
1058431 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
6025 {
6026 11121 ret = ((GuyH::getNPC()->x).getZLong());
6027 11121 }
6028 else
6029 {
6030 1047310 ret = (int32_t(GuyH::getNPC()->x) * 10000);
6031 }
6032 }
6033 1058431 break;
6034 }
6035
6036 case SPRITEMAXNPC:
6037 {
6038 //No bounds check, as this is a universal function and works from NULL pointers!
6039 ret = guys.getMax() * 10000;
6040 break;
6041 }
6042
6043 case NPCSUBMERGED:
6044 {
6045 if(GuyH::loadNPC(ri->guyref, "Submerged()") != SH::_NoError)
6046 {
6047 ret = -10000;
6048 }
6049 else
6050 {
6051 ret = ((GuyH::getNPC()->isSubmerged()) ? 10000 : 0);
6052
6053 }
6054 break;
6055 }
6056
6057
6058 case NPCY:
6059 //GET_NPC_VAR_FIX(y, "npc->Y") break;
6060 {
6061
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1035972 times.
1035972 if(GuyH::loadNPC(ri->guyref, "Y") != SH::_NoError)
6062 {
6063 ret = -10000;
6064 }
6065 else
6066 {
6067
2/2
✓ Branch 0 taken 11120 times.
✓ Branch 1 taken 1024852 times.
1035972 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
6068 {
6069 11120 ret = ((GuyH::getNPC()->y).getZLong());
6070 11120 }
6071 else
6072 {
6073 1024852 ret = (int32_t(GuyH::getNPC()->y) * 10000);
6074 }
6075 }
6076 1035972 break;
6077 }
6078
6079
6080 case NPCZ:
6081 //GET_NPC_VAR_FIX(z, "npc->Z") break;
6082 {
6083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 603413 times.
603413 if(GuyH::loadNPC(ri->guyref, "Z") != SH::_NoError)
6084 {
6085 ret = -10000;
6086 }
6087 else
6088 {
6089
2/2
✓ Branch 0 taken 556 times.
✓ Branch 1 taken 602857 times.
603413 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
6090 {
6091 556 ret = ((GuyH::getNPC()->z).getZLong());
6092 556 }
6093 else
6094 {
6095 602857 ret = (int32_t(GuyH::getNPC()->z) * 10000);
6096 }
6097 }
6098 603413 break;
6099 }
6100
6101 case NPCXOFS:
6102
1/2
✓ Branch 0 taken 2061476 times.
✗ Branch 1 not taken.
2061476 GET_NPC_VAR_FIX(xofs, "npc->DrawXOffset") break;
6103
6104 case NPCYOFS:
6105
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2062453 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2062453 times.
2062453 GET_NPC_VAR_FIX(yofs, "npc->DrawYOffset") ret-=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)*10000;
6106 2062453 break;
6107 case NPCSHADOWXOFS:
6108 GET_NPC_VAR_FIX(shadowxofs, "npc->ShadowXOffset") break;
6109
6110 case NPCSHADOWYOFS:
6111 GET_NPC_VAR_FIX(shadowyofs, "npc->ShadowYOffset") break;
6112
6113 case NPCTOTALDYOFFS:
6114 {
6115 if(GuyH::loadNPC(ri->guyref, "npc->TotalDYOffset") != SH::_NoError)
6116 {
6117 ret = -10000;
6118 }
6119 else
6120 {
6121 ret = ((int32_t(GuyH::getNPC()->yofs - (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset))
6122 + ((GuyH::getNPC()->switch_hooked && Hero.switchhookstyle == swRISE)
6123 ? -(8-(abs(Hero.switchhookclk-32)/4)) : 0)) * 10000);
6124 }
6125 break;
6126 }
6127
6128 case NPCZOFS:
6129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2061449 times.
2061449 GET_NPC_VAR_FIX(zofs, "npc->DrawZOffset") break;
6130
6131 //These variables are all different to the templates (casting for jump and step is slightly non-standard)
6132 case NPCJUMP:
6133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75622 times.
75622 if(GuyH::loadNPC(ri->guyref, "npc->Jump") != SH::_NoError)
6134 ret = -10000;
6135 else
6136 {
6137 75622 ret = GuyH::getNPC()->fall.getZLong() / -100;
6138
2/2
✓ Branch 0 taken 278 times.
✓ Branch 1 taken 75344 times.
75622 if (get_qr(qr_SPRITE_JUMP_IS_TRUNCATED)) ret = trunc(ret / 10000) * 10000;
6139 }
6140
6141 75622 break;
6142
6143 case NPCFAKEJUMP:
6144 if(GuyH::loadNPC(ri->guyref, "npc->FakeJump") != SH::_NoError)
6145 ret = -10000;
6146 else
6147 {
6148 ret = GuyH::getNPC()->fakefall.getZLong() / -100;
6149 if (get_qr(qr_SPRITE_JUMP_IS_TRUNCATED)) ret = trunc(ret / 10000) * 10000;
6150 }
6151
6152 break;
6153
6154
6155 case NPCSCALE:
6156 if ( get_qr(qr_OLDSPRITEDRAWS) )
6157 {
6158 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
6159 "npc->Scale");
6160 ret = -1; break;
6161 }
6162 if(GuyH::loadNPC(ri->guyref, "npc->Scale") != SH::_NoError)
6163 ret = -10000;
6164 else
6165 ret = (int32_t(GuyH::getNPC()->scale) * 100.0);
6166
6167 break;
6168
6169 case NPCIMMORTAL:
6170 if(GuyH::loadNPC(ri->guyref, "npc->Immortal") != SH::_NoError)
6171 ret = -10000;
6172 else
6173 ret = GuyH::getNPC()->immortal ? 10000 : 0;
6174 break;
6175
6176 case NPCNOSLIDE:
6177 if(GuyH::loadNPC(ri->guyref, "npc->NoSlide") != SH::_NoError)
6178 ret = -10000;
6179 else
6180 ret = (GuyH::getNPC()->knockbackflags & FLAG_NOSLIDE) ? 10000 : 0;
6181 break;
6182
6183 case NPCNOSCRIPTKB:
6184 if(GuyH::loadNPC(ri->guyref, "npc->NoScriptKnockback") != SH::_NoError)
6185 ret = -10000;
6186 else
6187 ret = (GuyH::getNPC()->knockbackflags & FLAG_NOSCRIPTKNOCKBACK) ? 10000 : 0;
6188 break;
6189
6190 case NPCKNOCKBACKSPEED:
6191 if(GuyH::loadNPC(ri->guyref, "npc->SlideSpeed") != SH::_NoError)
6192 ret = -10000;
6193 else
6194 ret = GuyH::getNPC()->knockbackSpeed * 10000;
6195 break;
6196
6197 case NPCSTEP:
6198
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 527244 times.
527244 if(GuyH::loadNPC(ri->guyref, "npc->Step") != SH::_NoError)
6199 ret = -10000;
6200 else
6201 {
6202
3/4
✓ Branch 0 taken 487718 times.
✓ Branch 1 taken 39526 times.
✓ Branch 2 taken 487718 times.
✗ Branch 3 not taken.
527244 if ( get_qr(qr_STEP_IS_FLOAT) || replay_is_active() )
6203 {
6204 527244 ret = ( ( (GuyH::getNPC()->step).getZLong() ) * 100 );
6205 527244 }
6206 //old, buggy code replication, round two: Go! -Z
6207 //else ret = ( ( (GuyH::getNPC()->step) * 100.0 ).getZLong() );
6208 else
6209 {
6210 double s2 = ( (GuyH::getNPC()->step).getZLong() );
6211 ret = int32_t(s2*100);
6212 //ret = int32_t( ( (GuyH::getNPC()->step) * 100.0 )) * 10000;
6213 }
6214 //else ret = int32_t(GuyH::getNPC()->step * fix(100.0)) * 10000;
6215
6216 //else
6217 //{
6218 //old, buggy code replication, round THREE: Go! -Z
6219 // double tmp = ( (GuyH::getNPC()->step) ) * 1000000.0;
6220 // ret = (int32_t)tmp;
6221 //}
6222 }
6223
6224 527244 break;
6225
6226 case NPCGRAVITY:
6227 if(GuyH::loadNPC(ri->guyref, "npc->Gravity") != SH::_NoError)
6228 ret = -10000;
6229 else
6230 ret = ((GuyH::getNPC()->moveflags & FLAG_OBEYS_GRAV) ? 10000 : 0);
6231
6232 break;
6233
6234
6235 case NPCID:
6236
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 22516406 times.
22516459 if(GuyH::loadNPC(ri->guyref, "npc->ID") != SH::_NoError)
6237 53 ret = -10000;
6238 else
6239 22516406 ret = (GuyH::getNPC()->id & 0xFFF) * 10000;
6240
6241 22516459 break;
6242
6243 case NPCISCORE:
6244 if(GuyH::loadNPC(ri->guyref, "npc->isCore") != SH::_NoError)
6245 ret = -10000;
6246 else
6247 ret = ((GuyH::getNPC()->isCore) ? 10000 : 0);
6248
6249 break;
6250
6251 case NPCSCRIPTUID:
6252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 598 times.
598 if(GuyH::loadNPC(ri->guyref, "npc->ScriptUID") != SH::_NoError)
6253 ret = -10000;
6254 else
6255 598 ret = ((GuyH::getNPC()->getScriptUID())); //literal, not *10000
6256
6257 598 break;
6258
6259 case NPCPARENTUID:
6260 if(GuyH::loadNPC(ri->guyref, "npc->ParentUID") != SH::_NoError)
6261 ret = -10000;
6262 else
6263 ret = ((GuyH::getNPC()->parent_script_UID)); //literal, not *10000
6264
6265 break;
6266
6267 //case EWPNPARENTUID:
6268 //if(0!=(s=checkEWpn(ri->ewpn, "ScriptUID")))
6269 // ret=(((weapon*)(s))->parent_script_UID); //literal, not *10000
6270
6271
6272 case NPCMFLAGS:
6273
2/2
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 3669986 times.
3670410 if(GuyH::loadNPC(ri->guyref, "npc->MiscFlags") != SH::_NoError)
6274 424 ret = -10000;
6275 else
6276 3669986 ret = GuyH::getMFlags() * 10000;
6277
6278 3670410 break;
6279
6280 //Indexed (two checks)
6281 case NPCDEFENSED:
6282 {
6283 167669 int32_t a = ri->d[rINDEX] / 10000;
6284
6285
2/4
✓ Branch 0 taken 167669 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 167669 times.
167669 if(GuyH::loadNPC(ri->guyref, "npc->Defense[]") != SH::_NoError ||
6286 167669 BC::checkBounds(a, 0, (edefLAST255), "npc->Defense[]") != SH::_NoError)
6287 ret = -10000;
6288 else
6289 167669 ret = GuyH::getNPC()->defense[a] * 10000;
6290 }
6291 167669 break;
6292
6293 case NPCHITBY:
6294 {
6295 268246 int32_t indx = ri->d[rINDEX] / 10000;
6296
6297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 268246 times.
268246 if(GuyH::loadNPC(ri->guyref, "npc->HitBy[]") != SH::_NoError )
6298 {
6299 ret = -10000; break;
6300 }
6301 else
6302 {
6303
2/3
✓ Branch 0 taken 134123 times.
✓ Branch 1 taken 134123 times.
✗ Branch 2 not taken.
268246 switch(indx)
6304 {
6305 //screen indixes
6306 case 0:
6307 case 1:
6308 case 2:
6309 case 3:
6310 case 8:
6311 case 9:
6312 case 10:
6313 case 11:
6314 case 12:
6315 case 16:
6316 {
6317 134123 ret = GuyH::getNPC()->hitby[indx] * 10000; // * 10000; //do not multiply by 10000! UIDs are not *10000!
6318 134123 break;
6319 }
6320 //UIDs
6321 case 4:
6322 case 5:
6323 case 6:
6324 case 7:
6325 case 13:
6326 case 14:
6327 case 15:
6328 {
6329 134123 ret = GuyH::getNPC()->hitby[indx]; // * 10000; //do not multiply by 10000! UIDs are not *10000!
6330 134123 break;
6331 }
6332 default: { Z_scripterrlog("Invalid index used for npc->HitBy[%d]. /n", indx); ret = -10000; break; }
6333 }
6334 268246 break;
6335 }
6336 }
6337
6338 //2.fuure compat.
6339
6340 case NPCSCRDEFENSED:
6341 {
6342 int32_t a = ri->d[rINDEX] / 10000;
6343
6344 if(GuyH::loadNPC(ri->guyref, "npc->ScriptDefense") != SH::_NoError ||
6345 BC::checkBounds(a, 0, edefSCRIPTDEFS_MAX, "npc->ScriptDefense") != SH::_NoError)
6346 ret = -10000;
6347 else
6348 ret = GuyH::getNPC()->defense[a+edefSCRIPT01] * 10000;
6349 }
6350 break;
6351
6352
6353 case NPCMISCD:
6354 {
6355 11380654 int32_t a = ri->d[rINDEX] / 10000;
6356
6357
3/4
✓ Branch 0 taken 11380615 times.
✓ Branch 1 taken 39 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11380615 times.
11380654 if(GuyH::loadNPC(ri->guyref, "npc->Misc") != SH::_NoError ||
6358 11380615 BC::checkMisc32(a, "npc->Misc") != SH::_NoError)
6359 39 ret = -10000;
6360 else
6361 11380615 ret = GuyH::getNPC()->miscellaneous[a];
6362 }
6363 11380654 break;
6364 case NPCINITD:
6365 {
6366 int32_t a = ri->d[rINDEX] / 10000;
6367
6368 if(GuyH::loadNPC(ri->guyref, "npc->InitD[]") != SH::_NoError )
6369 ret = -10000;
6370 else
6371 {
6372 //enemy *e = (enemy*)guys.spr(ri->guyref);
6373 ret = (int32_t)GuyH::getNPC()->initD[a];
6374 }
6375 }
6376 break;
6377
6378 case NPCSCRIPT:
6379 {
6380 if(GuyH::loadNPC(ri->guyref, "npc->Script") != SH::_NoError )
6381 ret = -10000;
6382 else
6383 {
6384 //enemy *e = (enemy*)guys.spr(ri->guyref);
6385 ret = (int32_t)GuyH::getNPC()->script * 10000;
6386 }
6387 }
6388 break;
6389
6390 case NPCDD: //Fized the size of this array. There are 15 total attribs, [0] to [14], not [0] to [9]. -Z
6391 {
6392 6431340 int32_t a = ri->d[rINDEX] / 10000;
6393
6394
2/4
✓ Branch 0 taken 6431340 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6431340 times.
6431340 if(GuyH::loadNPC(ri->guyref, "npc->Attributes") != SH::_NoError ||
6395 6431340 BC::checkBounds(a, 0, ( FFCore.getQuestHeaderInfo(vZelda) >= 0x255 ? 31 : 15 ), "npc->Attributes") != SH::_NoError)
6396 ret = -10000;
6397 else
6398 6431340 ret = GuyH::getNPCDMisc(a) * 10000;
6399 }
6400 6431340 break;
6401
6402 case NPCINVINC:
6403 if(GuyH::loadNPC(ri->guyref, "npc->InvFrames") != SH::_NoError)
6404 ret = -10000;
6405 else
6406 ret = (int32_t)GuyH::getNPC()->hclk * 10000;
6407
6408 break;
6409
6410 case NPCHASITEM:
6411 if(GuyH::loadNPC(ri->guyref, "npc->HasItem") != SH::_NoError)
6412 ret = 0;
6413 else
6414 ret = GuyH::getNPC()->itemguy?10000:0;
6415
6416 break;
6417
6418 case NPCRINGLEAD:
6419 if(GuyH::loadNPC(ri->guyref, "npc->Ringleader") != SH::_NoError)
6420 ret = 0;
6421 else
6422 ret = GuyH::getNPC()->leader?10000:0;
6423
6424 break;
6425
6426 case NPCSUPERMAN:
6427 if(GuyH::loadNPC(ri->guyref, "npc->Invincible") != SH::_NoError)
6428 ret = -10000;
6429 else
6430 ret = (int32_t)GuyH::getNPC()->superman * 10000;
6431
6432 break;
6433
6434 case NPCSHIELD:
6435 {
6436 int32_t indx = ri->d[rINDEX];
6437 if(GuyH::loadNPC(ri->guyref, "npc->Shield[]") == SH::_NoError)
6438 {
6439 switch(indx)
6440 {
6441 case 0:
6442 {
6443 ret = ((GuyH::getNPC()->flags&inv_front) ? 10000 : 0);
6444 break;
6445 }
6446 case 1:
6447 {
6448 ret = ((GuyH::getNPC()->flags&inv_left) ? 10000 : 0);
6449 break;
6450 }
6451 case 2:
6452 {
6453 ret = ((GuyH::getNPC()->flags&inv_right) ? 10000 : 0);
6454 break;
6455 }
6456 case 3:
6457 {
6458 ret = ((GuyH::getNPC()->flags&inv_back) ? 10000 : 0);
6459 break;
6460 }
6461 case 4: //shield can be broken
6462 {
6463 ret = ((GuyH::getNPC()->flags&guy_bkshield) ? 10000 : 0);
6464 break;
6465 }
6466 default:
6467 {
6468 Z_scripterrlog("Invalid Array Index passed to npc->Shield[]: %d\n", indx);
6469 break;
6470 }
6471 }
6472 }
6473 else
6474 {
6475 ret = -10000;
6476 break;
6477 }
6478 }
6479 break;
6480
6481 case NPCFROZENTILE:
6482 GET_NPC_VAR_INT(frozentile, "npc->FrozenTile"); break;
6483
6484 case NPCFROZENCSET:
6485 GET_NPC_VAR_INT(frozencset, "npc->FrozenCSet"); break;
6486
6487 case NPCFROZEN:
6488 GET_NPC_VAR_INT(frozenclock, "npc->Frozen"); break;
6489
6490
6491 case NPCBEHAVIOUR:
6492 {
6493 if(GuyH::loadNPC(ri->guyref, "npc->Behaviour[]") != SH::_NoError)
6494 {
6495 ret = -10000;
6496 break;
6497 }
6498
6499 int32_t index = vbound(ri->d[rINDEX]/10000,0,4);
6500 switch(index)
6501 {
6502 case 0:
6503 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG1)?10000:0; break;
6504 case 1:
6505 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG2)?10000:0; break;
6506 case 2:
6507 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG3)?10000:0; break;
6508 case 3:
6509 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG4)?10000:0; break;
6510 case 4:
6511 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG5)?10000:0; break;
6512 case 5:
6513 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG6)?10000:0; break;
6514 case 6:
6515 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG7)?10000:0; break;
6516 case 7:
6517 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG8)?10000:0; break;
6518 case 8:
6519 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG9)?10000:0; break;
6520 case 9:
6521 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG10)?10000:0; break;
6522 case 10:
6523 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG11)?10000:0; break;
6524 case 11:
6525 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG12)?10000:0; break;
6526 case 12:
6527 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG13)?10000:0; break;
6528 case 13:
6529 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG14)?10000:0; break;
6530 case 14:
6531 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG15)?10000:0; break;
6532 case 15:
6533 ret=(GuyH::getNPC()->editorflags & ENEMY_FLAG16)?10000:0; break;
6534
6535 default:
6536 ret = 0; break;
6537 }
6538
6539 break;
6540 }
6541
6542 case NPCFALLCLK:
6543 if(GuyH::loadNPC(ri->guyref, "npc->Falling") == SH::_NoError)
6544 {
6545 ret = GuyH::getNPC()->fallclk * 10000;
6546 }
6547 break;
6548
6549 case NPCFALLCMB:
6550 if(GuyH::loadNPC(ri->guyref, "npc->FallCombo") == SH::_NoError)
6551 {
6552 ret = GuyH::getNPC()->fallCombo * 10000;
6553 }
6554 break;
6555
6556 case NPCDROWNCLK:
6557 if(GuyH::loadNPC(ri->guyref, "npc->Drowning") == SH::_NoError)
6558 {
6559 ret = GuyH::getNPC()->drownclk * 10000;
6560 }
6561 break;
6562
6563 case NPCDROWNCMB:
6564 if(GuyH::loadNPC(ri->guyref, "npc->DrownCombo") == SH::_NoError)
6565 {
6566 ret = GuyH::getNPC()->drownCombo * 10000;
6567 }
6568 break;
6569
6570 case NPCFAKEZ:
6571 {
6572 if(GuyH::loadNPC(ri->guyref, "FakeZ") != SH::_NoError)
6573 {
6574 ret = -10000;
6575 }
6576 else
6577 {
6578 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
6579 {
6580 ret = ((GuyH::getNPC()->fakez).getZLong());
6581 }
6582 else
6583 {
6584 ret = (int32_t(GuyH::getNPC()->fakez) * 10000);
6585 }
6586 }
6587 break;
6588 }
6589
6590 case NPCMOVEFLAGS:
6591 {
6592 if(GuyH::loadNPC(ri->guyref, "npc->MoveFlags[]") == SH::_NoError)
6593 {
6594 int32_t indx = ri->d[rINDEX]/10000;
6595 if(BC::checkBounds(indx, 0, 15, "npc->MoveFlags[]") != SH::_NoError)
6596 ret = 0; //false
6597 else
6598 {
6599 //All bits, in order, of a single byte; just use bitwise
6600 ret = (GuyH::getNPC()->moveflags & (1<<indx)) ? 10000 : 0;
6601 }
6602 }
6603 break;
6604 }
6605
6606 case NPCGLOWRAD:
6607 if(GuyH::loadNPC(ri->guyref, "npc->LightRadius") == SH::_NoError)
6608 {
6609 ret = GuyH::getNPC()->glowRad * 10000;
6610 }
6611 break;
6612
6613 case NPCGLOWSHP:
6614 if(GuyH::loadNPC(ri->guyref, "npc->LightShape") == SH::_NoError)
6615 {
6616 ret = GuyH::getNPC()->glowShape * 10000;
6617 }
6618 break;
6619
6620 case NPCSHADOWSPR:
6621 if(GuyH::loadNPC(ri->guyref, "npc->ShadowSprite") == SH::_NoError)
6622 {
6623 ret = GuyH::getNPC()->spr_shadow * 10000;
6624 }
6625 break;
6626 case NPCSPAWNSPR:
6627 if(GuyH::loadNPC(ri->guyref, "npc->SpawnSprite") == SH::_NoError)
6628 {
6629 ret = GuyH::getNPC()->spr_spawn * 10000;
6630 }
6631 break;
6632 case NPCDEATHSPR:
6633 if(GuyH::loadNPC(ri->guyref, "npc->DeathSprite") == SH::_NoError)
6634 {
6635 ret = GuyH::getNPC()->spr_death * 10000;
6636 }
6637 break;
6638 case NPCSWHOOKED:
6639 if(GuyH::loadNPC(ri->guyref, "npc->SwitchHooked") == SH::_NoError)
6640 {
6641 ret = GuyH::getNPC()->switch_hooked ? 10000 : 0;
6642 }
6643 break;
6644 case NPCCANFLICKER:
6645 if(GuyH::loadNPC(ri->guyref, "npc->InvFlicker") == SH::_NoError)
6646 {
6647 ret = GuyH::getNPC()->getCanFlicker() ? 10000 : 0;
6648 }
6649 break;
6650
6651
6652
6653 ///----------------------------------------------------------------------------------------------------//
6654 //LWeapon Variables
6655 case LWPNSPECIAL:
6656 if(0!=(s=checkLWpn(ri->lwpn,"Special")))
6657 ret=((int32_t)((weapon*)(s))->specialinfo)*10000;
6658
6659
6660 break;
6661
6662 case LWPNSCALE:
6663 if ( get_qr(qr_OLDSPRITEDRAWS) )
6664 {
6665 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
6666 "lweapon->Scale");
6667 ret = -1; break;
6668 }
6669 if(0!=(s=checkLWpn(ri->lwpn,"Scale")))
6670 ret=((int32_t)((weapon*)(s))->scale)*100.0;
6671
6672 break;
6673
6674 case LWPNX:
6675
2/2
✓ Branch 0 taken 13756 times.
✓ Branch 1 taken 700149 times.
713905 if(0!=(s=checkLWpn(ri->lwpn,"X")))
6676 {
6677
2/2
✓ Branch 0 taken 153140 times.
✓ Branch 1 taken 547009 times.
700149 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
6678 {
6679 153140 ret=(((weapon*)(s))->x).getZLong();
6680 153140 }
6681 else
6682 547009 ret=((int32_t)((weapon*)(s))->x)*10000;
6683 700149 }
6684
6685 713905 break;
6686
6687 case SPRITEMAXLWPN:
6688 {
6689 //No bounds check, as this is a universal function and works from NULL pointers!
6690 ret = Lwpns.getMax() * 10000;
6691 break;
6692 }
6693
6694 case LWPNY:
6695
2/2
✓ Branch 0 taken 13756 times.
✓ Branch 1 taken 695675 times.
709431 if(0!=(s=checkLWpn(ri->lwpn,"Y")))
6696 {
6697
2/2
✓ Branch 0 taken 153140 times.
✓ Branch 1 taken 542535 times.
695675 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
6698 {
6699 153140 ret=(((weapon*)(s))->y).getZLong();
6700 153140 }
6701 else
6702 542535 ret=((int32_t)((weapon*)(s))->y)*10000;
6703 695675 }
6704 709431 break;
6705
6706 case LWPNZ:
6707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55748 times.
55748 if(0!=(s=checkLWpn(ri->lwpn,"Z")))
6708 {
6709
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 55746 times.
55748 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
6710 {
6711 2 ret=(((weapon*)(s))->z).getZLong();
6712 2 }
6713 else
6714 55746 ret=((int32_t)((weapon*)(s))->z)*10000;
6715 55748 }
6716
6717 55748 break;
6718
6719 case LWPNJUMP:
6720 if(0!=(s=checkLWpn(ri->lwpn,"Jump")))
6721 {
6722 ret = ((weapon*)(s))->fall.getZLong() / -100;
6723 if (get_qr(qr_SPRITE_JUMP_IS_TRUNCATED)) ret = trunc(ret / 10000) * 10000;
6724 }
6725
6726 break;
6727
6728 case LWPNFAKEJUMP:
6729 if(0!=(s=checkLWpn(ri->lwpn,"FakeJump")))
6730 {
6731 ret = ((weapon*)(s))->fakefall.getZLong() / -100;
6732 if (get_qr(qr_SPRITE_JUMP_IS_TRUNCATED)) ret = trunc(ret / 10000) * 10000;
6733 }
6734
6735 break;
6736
6737 case LWPNDIR:
6738
1/2
✓ Branch 0 taken 67667 times.
✗ Branch 1 not taken.
67667 if(0!=(s=checkLWpn(ri->lwpn,"Dir")))
6739 67667 ret=((weapon*)(s))->dir*10000;
6740
6741 67667 break;
6742
6743 case LWPNGRAVITY:
6744 if(0!=(s=checkLWpn(ri->lwpn,"Gravity")))
6745 ret= (((weapon*)(s))->moveflags & FLAG_OBEYS_GRAV) ? 10000 : 0;
6746
6747 break;
6748
6749 case LWPNSTEP:
6750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1329 times.
1329 if(0!=(s=checkLWpn(ri->lwpn,"Step")))
6751 {
6752
3/4
✓ Branch 0 taken 1134 times.
✓ Branch 1 taken 195 times.
✓ Branch 2 taken 1134 times.
✗ Branch 3 not taken.
1329 if ( get_qr(qr_STEP_IS_FLOAT) || replay_is_active() )
6753 {
6754 1329 ret=((weapon*)s)->step.getZLong() * 100;
6755 1329 }
6756 //old, buggy code replication, round two: Go! -Z
6757 //else ret = ( ( ( ((weapon*)s)->step ) * 100.0 ).getZLong() );
6758
6759 //else
6760 //{
6761 //old, buggy code replication, round THREE: Go! -Z
6762 // double tmp = ( ((weapon*)s)->step.getFloat() ) * 1000000.0;
6763 // ret = (int32_t)tmp;
6764 //}
6765
6766 //old, buggy code replication, round FOUR: Go! -Z
6767 else ret = (int32_t)((float)((weapon*)s)->step * 1000000.0);
6768 1329 }
6769 1329 break;
6770
6771 case LWPNANGLE:
6772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(0!=(s=checkLWpn(ri->lwpn,"Angle")))
6773 2 ret=(int32_t)(((weapon*)(s))->angle*10000);
6774
6775 2 break;
6776
6777 case LWPNDEGANGLE:
6778 if(0!=(s=checkLWpn(ri->lwpn,"DegAngle")))
6779 {
6780 ret=(int32_t)(((weapon*)(s))->angle*(180.0 / PI)*10000);
6781 }
6782
6783 break;
6784
6785 case LWPNVX:
6786 if(0!=(s=checkLWpn(ri->lwpn,"Vx")))
6787 {
6788 if (((weapon*)(s))->angular)
6789 ret = int32_t(zc::math::Cos(((weapon*)s)->angle)*10000.0*((weapon*)s)->step);
6790 else
6791 {
6792 switch(NORMAL_DIR(((weapon*)(s))->dir))
6793 {
6794 case l_up:
6795 case l_down:
6796 case left:
6797 ret = int32_t(-10000.0*((weapon*)s)->step);
6798 break;
6799
6800 case r_down:
6801 case r_up:
6802 case right:
6803 ret = int32_t(10000.0*((weapon*)s)->step);
6804 break;
6805
6806 default:
6807 ret = 0;
6808 break;
6809 }
6810 }
6811 }
6812
6813 break;
6814
6815 case LWPNVY:
6816 if(0!=(s=checkLWpn(ri->lwpn,"Vy")))
6817 {
6818 if (((weapon*)(s))->angular)
6819 ret = int32_t(zc::math::Sin(((weapon*)s)->angle)*10000.0*((weapon*)s)->step);
6820 else
6821 {
6822 switch(NORMAL_DIR(((weapon*)(s))->dir))
6823 {
6824 case l_up:
6825 case r_up:
6826 case up:
6827 ret = int32_t(-10000.0*((weapon*)s)->step);
6828 break;
6829 case l_down:
6830 case r_down:
6831 case down:
6832 ret = int32_t(10000.0*((weapon*)s)->step);
6833 break;
6834
6835 default:
6836 ret = 0;
6837 break;
6838 }
6839 }
6840 }
6841
6842 break;
6843
6844 case LWPNANGULAR:
6845 if(0!=(s=checkLWpn(ri->lwpn,"Angular")))
6846 ret=((weapon*)(s))->angular*10000;
6847
6848 break;
6849
6850 case LWPNAUTOROTATE:
6851 if(0!=(s=checkLWpn(ri->lwpn,"AutoRotate")))
6852 ret=((weapon*)(s))->autorotate*10000;
6853
6854 break;
6855
6856 case LWPNBEHIND:
6857 if(0!=(s=checkLWpn(ri->lwpn,"Behind")))
6858 ret=((weapon*)(s))->behind*10000;
6859
6860 break;
6861
6862 case LWPNDRAWTYPE:
6863 if(0!=(s=checkLWpn(ri->lwpn,"DrawStyle")))
6864 ret=((weapon*)(s))->drawstyle*10000;
6865
6866 break;
6867
6868 case LWPNPOWER:
6869
2/2
✓ Branch 0 taken 85829 times.
✓ Branch 1 taken 1 times.
85830 if(0!=(s=checkLWpn(ri->lwpn,"Damage")))
6870 85829 ret=((weapon*)(s))->power*10000;
6871
6872 85830 break;
6873 /*
6874 case LWPNRANGE:
6875 if(0!=(s=checkLWpn(ri->lwpn,"Range")))
6876 ret=((weapon*)(s))->scriptrange*10000;
6877
6878 break;
6879 */
6880 case LWPNDEAD:
6881
1/2
✓ Branch 0 taken 1122 times.
✗ Branch 1 not taken.
1122 if(0!=(s=checkLWpn(ri->lwpn,"DeadState")))
6882 1122 ret=((weapon*)(s))->dead*10000;
6883
6884 1122 break;
6885
6886 case LWPNID:
6887
2/2
✓ Branch 0 taken 3771488 times.
✓ Branch 1 taken 13757 times.
3785245 if(0!=(s=checkLWpn(ri->lwpn,"ID")))
6888 3771488 ret=((weapon*)(s))->id*10000;
6889
6890 3785245 break;
6891
6892 case LWPNTILE:
6893
1/2
✓ Branch 0 taken 49772 times.
✗ Branch 1 not taken.
49772 if(0!=(s=checkLWpn(ri->lwpn,"Tile")))
6894 49772 ret=((weapon*)(s))->tile*10000;
6895
6896 49772 break;
6897
6898 case LWPNSCRIPTTILE:
6899 if(0!=(s=checkLWpn(ri->lwpn,"ScriptTile")))
6900 ret=((weapon*)(s))->scripttile*10000;
6901
6902 break;
6903
6904 case LWPNSCRIPTFLIP:
6905 if(0!=(s=checkLWpn(ri->lwpn,"ScriptFlip")))
6906 ret=((weapon*)(s))->scriptflip*10000;
6907
6908 break;
6909
6910 case LWPNCSET:
6911
1/2
✓ Branch 0 taken 49794 times.
✗ Branch 1 not taken.
49794 if(0!=(s=checkLWpn(ri->lwpn,"CSet")))
6912 49794 ret=((weapon*)(s))->cs*10000;
6913
6914 49794 break;
6915
6916 case LWPNFLASHCSET:
6917 if(0!=(s=checkLWpn(ri->lwpn,"FlashCSet")))
6918 ret=(((weapon*)(s))->o_cset>>4)*10000;
6919
6920 break;
6921
6922 case LWPNFRAMES:
6923
1/2
✓ Branch 0 taken 3289 times.
✗ Branch 1 not taken.
3289 if(0!=(s=checkLWpn(ri->lwpn,"NumFrames")))
6924 3289 ret=((weapon*)(s))->frames*10000;
6925
6926 3289 break;
6927
6928 case LWPNFRAME:
6929 if(0!=(s=checkLWpn(ri->lwpn,"Frame")))
6930 ret=((weapon*)(s))->aframe*10000;
6931
6932 break;
6933
6934 case LWPNASPEED:
6935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3289 times.
3289 if(0!=(s=checkLWpn(ri->lwpn,"ASpeed")))
6936 3289 ret=((weapon*)(s))->o_speed*10000;
6937
6938 3289 break;
6939
6940 case LWPNFLASH:
6941 if(0!=(s=checkLWpn(ri->lwpn,"Flash")))
6942 ret=((weapon*)(s))->flash*10000;
6943
6944 break;
6945
6946 case LWPNFLIP:
6947 if(0!=(s=checkLWpn(ri->lwpn,"Flip")))
6948 ret=((weapon*)(s))->flip*10000;
6949
6950 break;
6951
6952 case LWPNCOUNT:
6953 1094820 ret=Lwpns.Count()*10000;
6954 1094820 break;
6955
6956 case LWPNEXTEND:
6957 if(0!=(s=checkLWpn(ri->lwpn,"Extend")))
6958 ret=((weapon*)(s))->extend*10000;
6959
6960 break;
6961
6962 case LWPNOTILE:
6963
1/2
✓ Branch 0 taken 830567 times.
✗ Branch 1 not taken.
830567 if(0!=(s=checkLWpn(ri->lwpn,"OriginalTile")))
6964 830567 ret=((weapon*)(s))->o_tile*10000;
6965
6966 830567 break;
6967
6968 case LWPNOCSET:
6969 if(0!=(s=checkLWpn(ri->lwpn,"OriginalCSet")))
6970 ret=(((weapon*)(s))->o_cset&15)*10000;
6971
6972 break;
6973
6974 case LWPNHXOFS:
6975
2/2
✓ Branch 0 taken 121386 times.
✓ Branch 1 taken 13756 times.
135142 if(0!=(s=checkLWpn(ri->lwpn,"HitXOffset")))
6976 121386 ret=(((weapon*)(s))->hxofs)*10000;
6977
6978 135142 break;
6979
6980 case LWPNHYOFS:
6981
2/2
✓ Branch 0 taken 13756 times.
✓ Branch 1 taken 118638 times.
132394 if(0!=(s=checkLWpn(ri->lwpn,"HitYOffset")))
6982 118638 ret=(((weapon*)(s))->hyofs)*10000;
6983
6984 132394 break;
6985
6986 case LWPNXOFS:
6987 if(0!=(s=checkLWpn(ri->lwpn,"DrawXOffset")))
6988 ret=((int32_t)(((weapon*)(s))->xofs))*10000;
6989
6990 break;
6991
6992 case LWPNYOFS:
6993 if(0!=(s=checkLWpn(ri->lwpn,"DrawYOffset")))
6994 ret=((int32_t)(((weapon*)(s))->yofs-(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)))*10000;
6995
6996 break;
6997
6998 case LWPNSHADOWXOFS:
6999 if(0!=(s=checkLWpn(ri->lwpn,"ShadowXOffset")))
7000 ret=((int32_t)(((weapon*)(s))->shadowxofs))*10000;
7001
7002 break;
7003
7004 case LWPNSHADOWYOFS:
7005 if(0!=(s=checkLWpn(ri->lwpn,"ShadowYOffset")))
7006 ret=((int32_t)(((weapon*)(s))->shadowyofs))*10000;
7007
7008 break;
7009
7010 case LWPNTOTALDYOFFS:
7011 if(0!=(s=checkLWpn(ri->lwpn,"TotalDYOffset")))
7012 ret = ((int32_t)(((weapon*)(s))->yofs-(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset))
7013 + ((((weapon*)(s))->switch_hooked && Hero.switchhookstyle == swRISE)
7014 ? -(8-(abs(Hero.switchhookclk-32)/4)) : 0)) * 10000;
7015 break;
7016
7017 case LWPNZOFS:
7018 if(0!=(s=checkLWpn(ri->lwpn,"DrawZOffset")))
7019 ret=((int32_t)(((weapon*)(s))->zofs))*10000;
7020
7021 break;
7022
7023 case LWPNHXSZ:
7024
2/2
✓ Branch 0 taken 13756 times.
✓ Branch 1 taken 119380 times.
133136 if(0!=(s=checkLWpn(ri->lwpn,"HitWidth")))
7025 119380 ret=(((weapon*)(s))->hit_width)*10000;
7026
7027 133136 break;
7028
7029 case LWPNHYSZ:
7030
2/2
✓ Branch 0 taken 121335 times.
✓ Branch 1 taken 13756 times.
135091 if(0!=(s=checkLWpn(ri->lwpn,"HitHeight")))
7031 121335 ret=(((weapon*)(s))->hit_height)*10000;
7032
7033 135091 break;
7034
7035 case LWPNHZSZ:
7036
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27874 times.
27874 if(0!=(s=checkLWpn(ri->lwpn,"HitZHeight")))
7037 27874 ret=(((weapon*)(s))->hzsz)*10000;
7038
7039 27874 break;
7040
7041 case LWPNTXSZ:
7042
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25249 times.
25249 if(0!=(s=checkLWpn(ri->lwpn,"TileWidth")))
7043 25249 ret=(((weapon*)(s))->txsz)*10000;
7044
7045 25249 break;
7046
7047 case LWPNTYSZ:
7048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25249 times.
25249 if(0!=(s=checkLWpn(ri->lwpn,"TileHeight")))
7049 25249 ret=(((weapon*)(s))->tysz)*10000;
7050
7051 25249 break;
7052
7053 case LWPNMISCD:
7054
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1553638 times.
1553638 if(0!=(s=checkLWpn(ri->lwpn,"Misc")))
7055 {
7056 1553638 int32_t a = vbound(ri->d[rINDEX]/10000,0,31);
7057 1553638 ret=(((weapon*)(s))->miscellaneous[a]);
7058 1553638 }
7059
7060 1553638 break;
7061
7062 case LWPNCOLLDET:
7063
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4320 times.
4320 if(0!=(s=checkLWpn(ri->lwpn,"CollDetection")))
7064 4320 ret=(((weapon*)(s))->scriptcoldet)*10000;
7065
7066 4320 break;
7067
7068 case LWPNENGINEANIMATE:
7069 if(0!=(s=checkLWpn(ri->lwpn,"Animation")))
7070 ret=(((weapon*)(s))->do_animation)*10000;
7071
7072 break;
7073
7074 case LWPNPARENT:
7075 if(0!=(s=checkLWpn(ri->lwpn,"Parent")))
7076 ret=(((weapon*)(s))->parentitem)*10000;
7077
7078 break;
7079
7080 case LWPNLEVEL:
7081 if(0!=(s=checkLWpn(ri->lwpn,"Level")))
7082 ret=(((weapon*)(s))->type)*10000;
7083
7084 break;
7085
7086 case LWPNSCRIPT:
7087 if(0!=(s=checkLWpn(ri->lwpn,"Script")))
7088 ret=(((weapon*)(s))->weaponscript)*10000;
7089
7090 break;
7091
7092 case LWPNUSEWEAPON:
7093
1/2
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
179 if(0!=(s=checkLWpn(ri->lwpn,"Weapon")))
7094 179 ret=(((weapon*)(s))->useweapon)*10000;
7095
7096 179 break;
7097
7098 case LWPNUSEDEFENCE:
7099 if(0!=(s=checkLWpn(ri->lwpn,"Defense")))
7100 ret=(((weapon*)(s))->usedefence)*10000;
7101
7102 break;
7103
7104 case LWPNINITD:
7105 {
7106 180 int32_t a = vbound((ri->d[rINDEX] / 10000),0,7);
7107
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 if(0!=(s=checkLWpn(ri->lwpn,"InitD[]")))
7108 {
7109 180 ret=(((weapon*)(s))->weap_initd[a]);
7110 180 }
7111 180 break;
7112 }
7113
7114 case LWEAPONSCRIPTUID:
7115 if(0!=(s=checkLWpn(ri->lwpn,"ScriptUID")))
7116 ret=(((weapon*)(s))->script_UID); //literal, not *10000
7117
7118 break;
7119
7120 case LWPNROTATION:
7121 if ( get_qr(qr_OLDSPRITEDRAWS) )
7122 {
7123 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
7124 "lweapon->Rotation");
7125 ret = -1; break;
7126 }
7127 if(0!=(s=checkLWpn(ri->lwpn,"Rotation")))
7128 ret=((weapon*)(s))->rotation*10000;
7129
7130 break;
7131
7132 case LWPNFALLCLK:
7133 if(0!=(s=checkLWpn(ri->lwpn,"Falling")))
7134 {
7135 ret = ((weapon*)(s))->fallclk * 10000;
7136 }
7137 break;
7138
7139 case LWPNFALLCMB:
7140 if(0!=(s=checkLWpn(ri->lwpn,"FallCombo")))
7141 {
7142 ret = ((weapon*)(s))->fallCombo * 10000;
7143 }
7144 break;
7145
7146 case LWPNDROWNCLK:
7147 if(0!=(s=checkLWpn(ri->lwpn,"Drowning")))
7148 {
7149 ret = ((weapon*)(s))->drownclk * 10000;
7150 }
7151 break;
7152
7153 case LWPNDROWNCMB:
7154 if(0!=(s=checkLWpn(ri->lwpn,"DrownCombo")))
7155 {
7156 ret = ((weapon*)(s))->drownCombo * 10000;
7157 }
7158 break;
7159
7160 case LWPNFAKEZ:
7161 if(0!=(s=checkLWpn(ri->lwpn,"FakeZ")))
7162 {
7163 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
7164 {
7165 ret=(((weapon*)(s))->fakez).getZLong();
7166 }
7167 else
7168 ret=((int32_t)((weapon*)(s))->fakez)*10000;
7169 }
7170 break;
7171
7172 case LWPNMOVEFLAGS:
7173 {
7174 if(0!=(s=checkLWpn(ri->lwpn,"MoveFlags[]")))
7175 {
7176 int32_t indx = ri->d[rINDEX]/10000;
7177 if(BC::checkBounds(indx, 0, 10, "lweapon->MoveFlags[]") != SH::_NoError)
7178 ret = 0; //false
7179 else
7180 {
7181 //All bits, in order, of a single byte; just use bitwise
7182 ret = (((weapon*)(s))->moveflags & (1<<indx)) ? 10000 : 0;
7183 }
7184 }
7185 break;
7186 }
7187 case LWPNFLAGS:
7188 {
7189 if(0!=(s=checkLWpn(ri->lwpn,"Flags[]")))
7190 {
7191 int32_t indx = ri->d[rINDEX]/10000;
7192 if(BC::checkBounds(indx, 0, WFLAG_MAX, "lweapon->Flags[]") != SH::_NoError)
7193 ret = 0; //false
7194 else
7195 {
7196 //All bits, in order, of a single byte; just use bitwise
7197 ret = (((weapon*)(s))->misc_wflags & (1<<indx)) ? 10000 : 0;
7198 }
7199 }
7200 break;
7201 }
7202
7203 case LWPNGLOWRAD:
7204 if(0!=(s=checkLWpn(ri->lwpn,"LightRadius")))
7205 {
7206 ret = ((weapon*)(s))->glowRad * 10000;
7207 }
7208 break;
7209
7210 case LWPNGLOWSHP:
7211 if(0!=(s=checkLWpn(ri->lwpn,"LightShape")))
7212 {
7213 ret = ((weapon*)(s))->glowShape * 10000;
7214 }
7215 break;
7216
7217 case LWPNUNBL:
7218 if(0!=(s=checkLWpn(ri->lwpn,"Unblockable")))
7219 {
7220 ret = ((weapon*)(s))->unblockable * 10000;
7221 }
7222 break;
7223
7224 case LWPNSHADOWSPR:
7225 if(0!=(s=checkLWpn(ri->lwpn,"ShadowSprite")))
7226 {
7227 ret = ((weapon*)(s))->spr_shadow * 10000;
7228 }
7229 break;
7230 case LWSWHOOKED:
7231 if(0!=(s=checkLWpn(ri->lwpn,"SwitchHooked")))
7232 {
7233 ret = s->switch_hooked ? 10000 : 0;
7234 }
7235 break;
7236 case LWPNTIMEOUT:
7237 if(0!=(s=checkLWpn(ri->lwpn,"Timeout")))
7238 {
7239 ret = ((weapon*)(s))->weap_timeout * 10000;
7240 }
7241 break;
7242 case LWPNDEATHITEM:
7243 if(0!=(s=checkLWpn(ri->lwpn,"DeathItem")))
7244 {
7245 ret = ((weapon*)(s))->death_spawnitem * 10000;
7246 }
7247 break;
7248 case LWPNDEATHDROPSET:
7249 if(0!=(s=checkLWpn(ri->lwpn,"DeathDropset")))
7250 {
7251 ret = ((weapon*)(s))->death_spawndropset * 10000;
7252 }
7253 break;
7254 case LWPNDEATHIPICKUP:
7255 if(0!=(s=checkLWpn(ri->lwpn,"DeathItemPFlags")))
7256 {
7257 ret = ((weapon*)(s))->death_item_pflags * 10000;
7258 }
7259 break;
7260 case LWPNDEATHSPRITE:
7261 if(0!=(s=checkLWpn(ri->lwpn,"DeathSprite")))
7262 {
7263 ret = ((weapon*)(s))->death_sprite * 10000;
7264 }
7265 break;
7266 case LWPNDEATHSFX:
7267 if(0!=(s=checkLWpn(ri->lwpn,"DeathSFX")))
7268 {
7269 ret = ((weapon*)(s))->death_sfx * 10000;
7270 }
7271 break;
7272 case LWPNLIFTLEVEL:
7273 if(0!=(s=checkLWpn(ri->lwpn,"LiftLevel")))
7274 {
7275 ret = ((weapon*)(s))->lift_level * 10000;
7276 }
7277 break;
7278 case LWPNLIFTTIME:
7279 if(0!=(s=checkLWpn(ri->lwpn,"LiftTime")))
7280 {
7281 ret = ((weapon*)(s))->lift_time * 10000;
7282 }
7283 break;
7284 case LWPNLIFTHEIGHT:
7285 if(0!=(s=checkLWpn(ri->lwpn,"LiftHeight")))
7286 {
7287 ret = ((weapon*)(s))->lift_height.getZLong();
7288 }
7289 break;
7290
7291 ///----------------------------------------------------------------------------------------------------//
7292 //EWeapon Variables
7293 case EWPNSCALE:
7294 if ( get_qr(qr_OLDSPRITEDRAWS) )
7295 {
7296 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
7297 "eweapon->Scale");
7298 ret = -1; break;
7299 }
7300 if(0!=(s=checkEWpn(ri->ewpn, "Scale")))
7301 ret=((int32_t)((weapon*)(s))->scale)*100.0;
7302
7303 break;
7304
7305 case EWPNX:
7306
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1267145 times.
1267145 if(0!=(s=checkEWpn(ri->ewpn, "X")))
7307 {
7308
2/2
✓ Branch 0 taken 148798 times.
✓ Branch 1 taken 1118347 times.
1267145 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
7309 {
7310 148798 ret=(((weapon*)(s))->x).getZLong();
7311 148798 }
7312 else
7313 1118347 ret=((int32_t)((weapon*)(s))->x)*10000;
7314 1267145 }
7315 1267145 break;
7316
7317 case SPRITEMAXEWPN:
7318 {
7319 //No bounds check, as this is a universal function and works from NULL pointers!
7320 ret = Ewpns.getMax() * 10000;
7321 break;
7322 }
7323
7324 case EWPNY:
7325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1266708 times.
1266708 if(0!=(s=checkEWpn(ri->ewpn, "Y")))
7326 {
7327
2/2
✓ Branch 0 taken 148686 times.
✓ Branch 1 taken 1118022 times.
1266708 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
7328 {
7329 148686 ret=(((weapon*)(s))->y).getZLong();
7330 148686 }
7331 else
7332 1118022 ret=((int32_t)((weapon*)(s))->y)*10000;
7333 1266708 }
7334 1266708 break;
7335
7336 case EWPNZ:
7337
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63485 times.
63485 if(0!=(s=checkEWpn(ri->ewpn, "Z")))
7338 {
7339
2/2
✓ Branch 0 taken 607 times.
✓ Branch 1 taken 62878 times.
63485 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
7340 {
7341 607 ret=(((weapon*)(s))->z).getZLong();
7342 607 }
7343 else
7344 62878 ret=((int32_t)((weapon*)(s))->z)*10000;
7345 63485 }
7346 63485 break;
7347
7348 case EWPNJUMP:
7349 if(0!=(s=checkEWpn(ri->ewpn, "Jump")))
7350 {
7351 ret = ((weapon*)(s))->fall.getZLong() / -100;
7352 if (get_qr(qr_SPRITE_JUMP_IS_TRUNCATED)) ret = trunc(ret / 10000) * 10000;
7353 }
7354
7355 break;
7356
7357 case EWPNFAKEJUMP:
7358 if(0!=(s=checkEWpn(ri->ewpn, "FakeJump")))
7359 {
7360 ret = ((weapon*)(s))->fakefall.getZLong() / -100;
7361 if (get_qr(qr_SPRITE_JUMP_IS_TRUNCATED)) ret = trunc(ret / 10000) * 10000;
7362 }
7363
7364 break;
7365
7366 case EWPNDIR:
7367
1/2
✓ Branch 0 taken 22679 times.
✗ Branch 1 not taken.
22679 if(0!=(s=checkEWpn(ri->ewpn, "Dir")))
7368 22679 ret=((weapon*)(s))->dir*10000;
7369
7370 22679 break;
7371
7372 case EWPNLEVEL:
7373 if(0!=(s=checkEWpn(ri->ewpn, "Level")))
7374 ret=((weapon*)(s))->type*10000;
7375
7376 break;
7377
7378 case EWPNGRAVITY:
7379 if(0!=(s=checkEWpn(ri->ewpn, "Gravity")))
7380 ret=((((weapon*)(s))->moveflags & FLAG_OBEYS_GRAV) ? 10000 : 0);
7381
7382 break;
7383
7384 case EWPNSTEP:
7385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 362690 times.
362690 if(0!=(s=checkEWpn(ri->ewpn, "Step")))
7386 {
7387
3/4
✓ Branch 0 taken 362528 times.
✓ Branch 1 taken 162 times.
✓ Branch 2 taken 362528 times.
✗ Branch 3 not taken.
362690 if ( get_qr(qr_STEP_IS_FLOAT) || replay_is_active() )
7388 {
7389 362690 ret=((weapon*)s)->step.getZLong() * 100;
7390 362690 }
7391 //old, buggy code replication, round two: Go! -Z
7392 //else ret = ( ( ( ((weapon*)s)->step ) * 100.0 ).getZLong() );
7393 //old, buggy code replication, round FOUR: Go! -Z
7394 else ret = (int32_t)((float)((weapon*)s)->step * 1000000.0);
7395 362690 }
7396 //else
7397 //{
7398 //old, buggy code replication, round THREE: Go! -Z
7399 // double tmp = ( ((weapon*)s)->step.getFloat() ) * 1000000.0;
7400 // ret = int32_t(tmp);
7401 //}
7402 362690 break;
7403
7404 case EWPNANGLE:
7405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 373525 times.
373525 if(0!=(s=checkEWpn(ri->ewpn,"Angle")))
7406 373525 ret=(int32_t)(((weapon*)(s))->angle*10000);
7407
7408 373525 break;
7409
7410 case EWPNDEGANGLE:
7411 if(0!=(s=checkEWpn(ri->ewpn,"DegAngle")))
7412 {
7413 ret=(int32_t)(((weapon*)(s))->angle*(180.0 / PI)*10000);
7414 }
7415
7416 break;
7417
7418 case EWPNVX:
7419 if(0!=(s=checkEWpn(ri->ewpn,"Vx")))
7420 {
7421 if (((weapon*)(s))->angular)
7422 ret = int32_t(zc::math::Cos(((weapon*)s)->angle)*10000.0*((weapon*)s)->step);
7423 else
7424 {
7425 switch(NORMAL_DIR(((weapon*)(s))->dir))
7426 {
7427 case l_up:
7428 case l_down:
7429 case left:
7430 ret = int32_t(-10000.0*((weapon*)s)->step);
7431 break;
7432 case r_up:
7433 case r_down:
7434 case right:
7435 ret = int32_t(10000.0*((weapon*)s)->step);
7436 break;
7437
7438 default:
7439 ret = 0;
7440 break;
7441 }
7442 }
7443 }
7444
7445 break;
7446
7447 case EWPNVY:
7448 if(0!=(s=checkEWpn(ri->ewpn,"Vy")))
7449 {
7450 if (((weapon*)(s))->angular)
7451 ret = int32_t(zc::math::Sin(((weapon*)s)->angle)*10000.0*((weapon*)s)->step);
7452 else
7453 {
7454 switch(NORMAL_DIR(((weapon*)(s))->dir))
7455 {
7456 case l_up:
7457 case r_up:
7458 case up:
7459 ret = int32_t(-10000.0*((weapon*)s)->step);
7460 break;
7461 case l_down:
7462 case r_down:
7463 case down:
7464 ret = int32_t(10000.0*((weapon*)s)->step);
7465 break;
7466
7467 default:
7468 ret = 0;
7469 break;
7470 }
7471 }
7472 }
7473
7474 break;
7475
7476
7477 case EWPNANGULAR:
7478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68688 times.
68688 if(0!=(s=checkEWpn(ri->ewpn,"Angular")))
7479 68688 ret=((weapon*)(s))->angular*10000;
7480
7481 68688 break;
7482
7483 case EWPNAUTOROTATE:
7484 if(0!=(s=checkEWpn(ri->ewpn,"AutoRotate")))
7485 ret=((weapon*)(s))->autorotate*10000;
7486
7487 break;
7488
7489 case EWPNBEHIND:
7490 if(0!=(s=checkEWpn(ri->ewpn,"Behind")))
7491 ret=((weapon*)(s))->behind*10000;
7492
7493 break;
7494
7495 case EWPNDRAWTYPE:
7496
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46359 times.
46359 if(0!=(s=checkEWpn(ri->ewpn,"DrawStyle")))
7497 46359 ret=((weapon*)(s))->drawstyle*10000;
7498
7499 46359 break;
7500
7501 case EWPNPOWER:
7502
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 90188 times.
90188 if(0!=(s=checkEWpn(ri->ewpn,"Damage")))
7503 90188 ret=((weapon*)(s))->power*10000;
7504
7505 90188 break;
7506
7507 case EWPNDEAD:
7508
1/2
✓ Branch 0 taken 154 times.
✗ Branch 1 not taken.
154 if(0!=(s=checkEWpn(ri->ewpn,"DeadState")))
7509 154 ret=((weapon*)(s))->dead*10000;
7510
7511 154 break;
7512
7513 case EWPNID:
7514
1/2
✓ Branch 0 taken 2150394 times.
✗ Branch 1 not taken.
2150394 if(0!=(s=checkEWpn(ri->ewpn,"ID")))
7515 2150394 ret=((weapon*)(s))->id*10000;
7516
7517 2150394 break;
7518
7519 case EWPNTILE:
7520
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106032 times.
106032 if(0!=(s=checkEWpn(ri->ewpn,"Tile")))
7521 106032 ret=((weapon*)(s))->tile*10000;
7522
7523 106032 break;
7524
7525 case EWPNSCRIPTTILE:
7526 if(0!=(s=checkEWpn(ri->ewpn,"ScriptTile")))
7527 ret=((weapon*)(s))->scripttile*10000;
7528
7529 break;
7530
7531 case EWPNSCRIPTFLIP:
7532 if(0!=(s=checkEWpn(ri->ewpn,"ScriptFlip")))
7533 ret=((weapon*)(s))->scriptflip*10000;
7534
7535 break;
7536
7537 case EWPNCSET:
7538
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24909 times.
24909 if(0!=(s=checkEWpn(ri->ewpn,"CSet")))
7539 24909 ret=((weapon*)(s))->cs*10000;
7540
7541 24909 break;
7542
7543 case EWPNFLASHCSET:
7544 if(0!=(s=checkEWpn(ri->ewpn,"FlashCSet")))
7545 ret=(((weapon*)(s))->o_cset>>4)*10000;
7546
7547 break;
7548
7549 case EWPNFRAMES:
7550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if(0!=(s=checkEWpn(ri->ewpn,"NumFrames")))
7551 70 ret=((weapon*)(s))->frames*10000;
7552
7553 70 break;
7554
7555 case EWPNFRAME:
7556 if(0!=(s=checkEWpn(ri->ewpn,"Frame")))
7557 ret=((weapon*)(s))->aframe*10000;
7558
7559 break;
7560
7561 case EWPNASPEED:
7562
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if(0!=(s=checkEWpn(ri->ewpn,"ASpeed")))
7563 70 ret=((weapon*)(s))->o_speed*10000;
7564
7565 70 break;
7566
7567 case EWPNFLASH:
7568 if(0!=(s=checkEWpn(ri->ewpn,"Flash")))
7569 ret=((weapon*)(s))->flash*10000;
7570
7571 break;
7572
7573 case EWPNFLIP:
7574 if(0!=(s=checkEWpn(ri->ewpn,"Flip")))
7575 ret=((weapon*)(s))->flip*10000;
7576
7577 break;
7578
7579 case EWPNROTATION:
7580
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 218 times.
218 if ( get_qr(qr_OLDSPRITEDRAWS) )
7581 {
7582 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
7583 "eweapon->Rotation");
7584 break;
7585 }
7586
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 218 times.
218 if(0!=(s=checkEWpn(ri->ewpn,"Rotation")))
7587 218 ret=((weapon*)(s))->rotation*10000;
7588
7589 218 break;
7590
7591 case EWPNCOUNT:
7592 1911385 ret=Ewpns.Count()*10000;
7593 1911385 break;
7594
7595 case EWPNEXTEND:
7596 if(0!=(s=checkEWpn(ri->ewpn,"Extend")))
7597 ret=((weapon*)(s))->extend*10000;
7598
7599 break;
7600
7601 case EWPNOTILE:
7602
1/2
✓ Branch 0 taken 2925 times.
✗ Branch 1 not taken.
2925 if(0!=(s=checkEWpn(ri->ewpn,"OriginalTile")))
7603 2925 ret=((weapon*)(s))->o_tile*10000;
7604
7605 2925 break;
7606
7607 case EWPNOCSET:
7608 if(0!=(s=checkEWpn(ri->ewpn,"OriginalCSet")))
7609 ret=(((weapon*)(s))->o_cset&15)*10000;
7610
7611 break;
7612
7613 case EWPNHXOFS:
7614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 65540 times.
65540 if(0!=(s=checkEWpn(ri->ewpn,"HitXOffset")))
7615 65540 ret=(((weapon*)(s))->hxofs)*10000;
7616
7617 65540 break;
7618
7619 case EWPNHYOFS:
7620
1/2
✓ Branch 0 taken 65540 times.
✗ Branch 1 not taken.
65540 if(0!=(s=checkEWpn(ri->ewpn,"HitYOffset")))
7621 65540 ret=(((weapon*)(s))->hyofs)*10000;
7622
7623 65540 break;
7624
7625 case EWPNXOFS:
7626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(0!=(s=checkEWpn(ri->ewpn,"DrawXOffset")))
7627 8 ret=((int32_t)(((weapon*)(s))->xofs))*10000;
7628
7629 8 break;
7630
7631 case EWPNYOFS:
7632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(0!=(s=checkEWpn(ri->ewpn,"DrawYOffset")))
7633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 ret=((int32_t)(((weapon*)(s))->yofs-(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)))*10000;
7634
7635 96 break;
7636
7637 case EWPNSHADOWXOFS:
7638 if(0!=(s=checkEWpn(ri->ewpn,"ShadowXOffset")))
7639 ret=((int32_t)(((weapon*)(s))->shadowxofs))*10000;
7640
7641 break;
7642
7643 case EWPNSHADOWYOFS:
7644 if(0!=(s=checkEWpn(ri->ewpn,"ShadowYOffset")))
7645 ret=((int32_t)(((weapon*)(s))->shadowyofs))*10000;
7646
7647 break;
7648 case EWPNTOTALDYOFFS:
7649 if(0!=(s=checkLWpn(ri->ewpn,"TotalDYOffset")))
7650 ret = ((int32_t)(((weapon*)(s))->yofs-(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset))
7651 + ((((weapon*)(s))->switch_hooked && Hero.switchhookstyle == swRISE)
7652 ? -(8-(abs(Hero.switchhookclk-32)/4)) : 0) * 10000);
7653 break;
7654
7655 case EWPNZOFS:
7656 if(0!=(s=checkEWpn(ri->ewpn,"DrawZOffset")))
7657 ret=((int32_t)(((weapon*)(s))->zofs))*10000;
7658
7659 break;
7660
7661 case EWPNHXSZ:
7662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62523 times.
62523 if(0!=(s=checkEWpn(ri->ewpn,"HitWidth")))
7663 62523 ret=(((weapon*)(s))->hit_width)*10000;
7664
7665 62523 break;
7666
7667 case EWPNHYSZ:
7668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62523 times.
62523 if(0!=(s=checkEWpn(ri->ewpn,"HitHeight")))
7669 62523 ret=(((weapon*)(s))->hit_height)*10000;
7670
7671 62523 break;
7672
7673 case EWPNHZSZ:
7674
1/2
✓ Branch 0 taken 12470 times.
✗ Branch 1 not taken.
12470 if(0!=(s=checkEWpn(ri->ewpn,"HitZHeight")))
7675 12470 ret=(((weapon*)(s))->hzsz)*10000;
7676
7677 12470 break;
7678
7679 case EWPNTXSZ:
7680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24497 times.
24497 if(0!=(s=checkEWpn(ri->ewpn,"TileWidth")))
7681 24497 ret=(((weapon*)(s))->txsz)*10000;
7682
7683 24497 break;
7684
7685 case EWPNTYSZ:
7686
1/2
✓ Branch 0 taken 24497 times.
✗ Branch 1 not taken.
24497 if(0!=(s=checkEWpn(ri->ewpn,"TileHeight")))
7687 24497 ret=(((weapon*)(s))->tysz)*10000;
7688
7689 24497 break;
7690
7691 case EWPNMISCD:
7692
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13780500 times.
13780500 if(0!=(s=checkEWpn(ri->ewpn,"Misc")))
7693 {
7694 13780500 int32_t a = vbound(ri->d[rINDEX]/10000,0,31);
7695 13780500 ret=(((weapon*)(s))->miscellaneous[a]);
7696 13780500 }
7697
7698 13780500 break;
7699
7700 case EWPNCOLLDET:
7701 if(0!=(s=checkEWpn(ri->ewpn,"CollDetection")))
7702 ret=(((weapon*)(s))->scriptcoldet)*10000;
7703
7704 break;
7705
7706 case EWPNENGINEANIMATE:
7707 if(0!=(s=checkEWpn(ri->ewpn,"Animation")))
7708 ret=(((weapon*)(s))->do_animation)*10000;
7709
7710 break;
7711
7712 case EWPNPARENT:
7713 if(0!=(s=checkEWpn(ri->ewpn, "Parent")))
7714 ret= ((get_qr(qr_OLDEWPNPARENT)) ? (((weapon*)(s))->parentid)*10000 : (((weapon*)(s))->parentid));
7715
7716 break;
7717
7718 case EWEAPONSCRIPTUID:
7719 if(0!=(s=checkEWpn(ri->ewpn, "ScriptUID")))
7720 ret=(((weapon*)(s))->script_UID); //literal, not *10000
7721
7722 break;
7723
7724 case EWPNPARENTUID:
7725 if(0!=(s=checkEWpn(ri->ewpn, "ParentUID")))
7726 ret=(((weapon*)(s))->parent_script_UID); //literal, not *10000
7727
7728 break;
7729
7730 case EWPNSCRIPT:
7731 if(0!=(s=checkEWpn(ri->ewpn,"Script")))
7732 ret=(((weapon*)(s))->weaponscript)*10000;
7733
7734 break;
7735
7736 case EWPNINITD:
7737 {
7738 16680 int32_t a = vbound((ri->d[rINDEX] / 10000),0,7);
7739
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16680 times.
16680 if(0!=(s=checkEWpn(ri->ewpn,"InitD[]")))
7740 {
7741 16680 ret=(((weapon*)(s))->weap_initd[a]);
7742 16680 }
7743 16680 break;
7744 }
7745
7746 case EWPNFALLCLK:
7747 if(0!=(s=checkEWpn(ri->ewpn,"Falling")))
7748 {
7749 ret = ((weapon*)(s))->fallclk * 10000;
7750 }
7751 break;
7752
7753 case EWPNFALLCMB:
7754 if(0!=(s=checkEWpn(ri->ewpn,"FallCombo")))
7755 {
7756 ret = ((weapon*)(s))->fallCombo * 10000;
7757 }
7758 break;
7759
7760 case EWPNDROWNCLK:
7761 if(0!=(s=checkEWpn(ri->ewpn,"Drowning")))
7762 {
7763 ret = ((weapon*)(s))->drownclk * 10000;
7764 }
7765 break;
7766
7767 case EWPNDROWNCMB:
7768 if(0!=(s=checkEWpn(ri->ewpn,"DrownCombo")))
7769 {
7770 ret = ((weapon*)(s))->drownCombo * 10000;
7771 }
7772 break;
7773 case EWPNFAKEZ:
7774 if(0!=(s=checkEWpn(ri->ewpn, "FakeZ")))
7775 {
7776 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
7777 {
7778 ret=(((weapon*)(s))->fakez).getZLong();
7779 }
7780 else
7781 ret=((int32_t)((weapon*)(s))->fakez)*10000;
7782 }
7783 break;
7784
7785 case EWPNMOVEFLAGS:
7786 {
7787 if(0!=(s=checkEWpn(ri->ewpn,"MoveFlags[]")))
7788 {
7789 int32_t indx = ri->d[rINDEX]/10000;
7790 if(BC::checkBounds(indx, 0, 10, "eweapon->MoveFlags[]") != SH::_NoError)
7791 ret = 0; //false
7792 else
7793 {
7794 //All bits, in order, of a single byte; just use bitwise
7795 ret = (((weapon*)(s))->moveflags & (1<<indx)) ? 10000 : 0;
7796 }
7797 }
7798 break;
7799 }
7800 case EWPNFLAGS:
7801 {
7802 if(0!=(s=checkEWpn(ri->ewpn,"Flags[]")))
7803 {
7804 int32_t indx = ri->d[rINDEX]/10000;
7805 if(BC::checkBounds(indx, 0, WFLAG_MAX, "eweapon->Flags[]") != SH::_NoError)
7806 ret = 0; //false
7807 else
7808 {
7809 //All bits, in order, of a single byte; just use bitwise
7810 ret = (((weapon*)(s))->misc_wflags & (1<<indx)) ? 10000 : 0;
7811 }
7812 }
7813 break;
7814 }
7815
7816 case EWPNGLOWRAD:
7817 if(0!=(s=checkEWpn(ri->ewpn,"LightRadius")))
7818 {
7819 ret = ((weapon*)(s))->glowRad * 10000;
7820 }
7821 break;
7822
7823 case EWPNGLOWSHP:
7824 if(0!=(s=checkEWpn(ri->ewpn,"LightShape")))
7825 {
7826 ret = ((weapon*)(s))->glowShape * 10000;
7827 }
7828 break;
7829
7830 case EWPNUNBL:
7831 if(0!=(s=checkEWpn(ri->ewpn,"Unblockable")))
7832 {
7833 ret = ((weapon*)(s))->unblockable * 10000;
7834 }
7835 break;
7836
7837 case EWPNSHADOWSPR:
7838 if(0!=(s=checkEWpn(ri->ewpn,"ShadowSprite")))
7839 {
7840 ret = ((weapon*)(s))->spr_shadow * 10000;
7841 }
7842 break;
7843 case EWSWHOOKED:
7844 if(0!=(s=checkEWpn(ri->ewpn,"SwitchHooked")))
7845 {
7846 ret = s->switch_hooked ? 10000 : 0;
7847 }
7848 break;
7849 case EWPNTIMEOUT:
7850 if(0!=(s=checkEWpn(ri->ewpn,"Timeout")))
7851 {
7852 ret = ((weapon*)(s))->weap_timeout * 10000;
7853 }
7854 break;
7855 case EWPNDEATHITEM:
7856 if(0!=(s=checkEWpn(ri->ewpn,"DeathItem")))
7857 {
7858 ret = ((weapon*)(s))->death_spawnitem * 10000;
7859 }
7860 break;
7861 case EWPNDEATHDROPSET:
7862 if(0!=(s=checkEWpn(ri->ewpn,"DeathDropset")))
7863 {
7864 ret = ((weapon*)(s))->death_spawndropset * 10000;
7865 }
7866 break;
7867 case EWPNDEATHIPICKUP:
7868 if(0!=(s=checkEWpn(ri->ewpn,"DeathItemPFlags")))
7869 {
7870 ret = ((weapon*)(s))->death_item_pflags * 10000;
7871 }
7872 break;
7873 case EWPNDEATHSPRITE:
7874 if(0!=(s=checkEWpn(ri->ewpn,"DeathSprite")))
7875 {
7876 ret = ((weapon*)(s))->death_sprite * 10000;
7877 }
7878 break;
7879 case EWPNDEATHSFX:
7880 if(0!=(s=checkEWpn(ri->ewpn,"DeathSFX")))
7881 {
7882 ret = ((weapon*)(s))->death_sfx * 10000;
7883 }
7884 break;
7885 case EWPNLIFTLEVEL:
7886 if(0!=(s=checkEWpn(ri->ewpn,"LiftLevel")))
7887 {
7888 ret = ((weapon*)(s))->lift_level * 10000;
7889 }
7890 break;
7891 case EWPNLIFTTIME:
7892 if(0!=(s=checkEWpn(ri->ewpn,"LiftTime")))
7893 {
7894 ret = ((weapon*)(s))->lift_time * 10000;
7895 }
7896 break;
7897 case EWPNLIFTHEIGHT:
7898 if(0!=(s=checkEWpn(ri->ewpn,"LiftHeight")))
7899 {
7900 ret = ((weapon*)(s))->lift_height.getZLong();
7901 }
7902 break;
7903
7904 /*
7905 case LWEAPONSCRIPTUID:
7906 if(0!=(s=checkLWpn(ri->lwpn,"ScriptUID")))
7907 ret=(((weapon*)(s))->getScriptUID()); //literal, not *10000
7908
7909 break;
7910 case EWEAPONSCRIPTUID:
7911 if(0!=(s=checkLWpn(ri->ewpn,"ScriptUID")))
7912 ret=(((weapon*)(s))->getScriptUID()); //literal, not *10000
7913
7914 break;
7915 */
7916
7917 ///----------------------------------------------------------------------------------------------------//
7918 //Game Info
7919
7920
7921 case GAMEPLAYFIELDOFS:
7922 ret = playing_field_offset*10000;
7923 break;
7924
7925 case GETPIXEL:
7926 ret=FFCore.do_getpixel();
7927 break;
7928
7929
7930 case ZELDAVERSION:
7931 ret = ZC_VERSION; //Do *not* multiply by 10,000!
7932 break;
7933 case ZELDABUILD:
7934 ret = (int32_t)VERSION_BUILD*10000;
7935 break;
7936
7937 case ZSCRIPTVERSION:
7938 {
7939 ret = (FFCore.quest_format[vLastCompile]) * 10000;
7940 break;
7941 }
7942
7943 case ZELDABETATYPE:
7944 {
7945 ret = int32_t(ALPHA_STATE*10000);
7946 break;
7947 }
7948 case ZELDABETA:
7949 {
7950 ret = int32_t(ALPHA_VER*10000);
7951 if(ZC_IS_NIGHTLY) //Nightly 111/112 should return '111.5' not '112'
7952 ret -= 5000;
7953 break;
7954 }
7955 case GAMEDEATHS:
7956 ret=game->get_deaths()*10000;
7957 break;
7958
7959 case GAMECHEAT:
7960 ret=cheat*10000;
7961 break;
7962
7963 case GAMEMAXCHEAT:
7964 ret=maxcheat*10000;
7965 break;
7966
7967 case GAMETIME:
7968 ret=game->get_time();
7969 break;// Can't multiply by 10000 or the maximum result is too big
7970 case ACTIVESSSPEED:
7971 ret=Hero.subscr_speed*10000;
7972 break;// Can't multiply by 10000 or the maximum result is too big
7973
7974 case GAMETIMEVALID:
7975 ret=game->get_timevalid()?10000:0;
7976 break;
7977
7978 case GAMEHASPLAYED:
7979 ret=game->get_hasplayed()?10000:0;
7980 break;
7981
7982 case TYPINGMODE:
7983 ret=FFCore.kb_typing_mode?10000:0;
7984 break;
7985
7986 case SKIPCREDITS:
7987 ret=FFCore.skip_ending_credits?10000:0;
7988 break;
7989
7990 case SKIPF6:
7991 ret=get_qr(qr_NOCONTINUE)?10000:0;
7992 break;
7993
7994 case GAMESTANDALONE:
7995 17 ret=standalone_mode?10000:0;
7996 17 break;
7997
7998 case GAMEGUYCOUNT:
7999 {
8000 26 int32_t mi = (currmap*MAPSCRSNORMAL)+(ri->d[rINDEX]/10000);
8001 26 ret=game->guys[mi]*10000;
8002 }
8003 26 break;
8004
8005 case GAMECONTSCR:
8006 678 ret=game->get_continue_scrn()*10000;
8007 678 break;
8008
8009 case GAMECONTDMAP:
8010 972 ret=game->get_continue_dmap()*10000;
8011 972 break;
8012
8013 case GAMEENTRSCR:
8014 14 ret=lastentrance*10000;
8015 14 break;
8016
8017 case GAMEENTRDMAP:
8018 471 ret=lastentrance_dmap*10000;
8019 471 break;
8020
8021 case GAMECOUNTERD:
8022 4013519 ret=game->get_counter((ri->d[rINDEX])/10000)*10000;
8023 4013519 break;
8024
8025 case GAMEMCOUNTERD:
8026 1586472 ret=game->get_maxcounter((ri->d[rINDEX])/10000)*10000;
8027 1586472 break;
8028
8029 case GAMEDCOUNTERD:
8030 15 ret=game->get_dcounter((ri->d[rINDEX])/10000)*10000;
8031 15 break;
8032
8033 case GAMEGENERICD:
8034 16 ret=game->get_generic((ri->d[rINDEX])/10000)*10000;
8035 16 break;
8036
8037 case GAMEMISC:
8038 {
8039 int32_t indx = ri->d[rINDEX]/10000;
8040 if ( indx < 0 || indx > 31 )
8041 {
8042 ret = -10000;
8043 Z_scripterrlog("Invalud index used to access Game->Misc: %d\n", indx);
8044 }
8045 else
8046 {
8047 ret = QMisc.questmisc[indx]*((get_qr(qr_OLDQUESTMISC)) ? 10000 : 1);
8048 }
8049 break;
8050 }
8051
8052 case GAMEITEMSD:
8053 ret=(game->item[(ri->d[rINDEX])/10000] ? 10000 : 0);
8054 break;
8055 case DISABLEDITEM:
8056 ret = (game->items_off[(ri->d[rINDEX])/10000] ? 10000 : 0);
8057 break;
8058 case GAMESUSPEND:
8059 {
8060 int32_t inx = (ri->d[rINDEX])/10000;
8061 if ( (unsigned) inx > (susptLAST-1) )
8062 {
8063 Z_scripterrlog("Invalid array index [%d] passed to Gme->Suspend[]\n");
8064 }
8065 ret = (( FFCore.system_suspend[inx] ) ? 10000 : 0);
8066 break;
8067 }
8068 case GAMELITEMSD:
8069 2365308 ret=game->lvlitems[(ri->d[rINDEX])/10000]*10000;
8070 2365308 break;
8071 case GAMELSWITCH:
8072 {
8073 int32_t ind = (ri->d[rINDEX])/10000;
8074 if(unsigned(ind) >= MAXLEVELS)
8075 ret = 0;
8076 else ret=game->lvlswitches[ind];
8077 break;
8078 }
8079 case GAMEGSWITCH:
8080 {
8081 int32_t ind = (ri->d[rINDEX])/10000;
8082 if(unsigned(ind) >= NUM_GSWITCHES)
8083 ret = 0;
8084 else ret=game->gswitch_timers[ind]*10000;
8085 break;
8086 }
8087 case GAMEBOTTLEST:
8088 ret=game->get_bottle_slot((ri->d[rINDEX])/10000)*10000;
8089 break;
8090
8091 case GAMELKEYSD:
8092 561132 ret=game->lvlkeys[(ri->d[rINDEX])/10000]*10000;
8093 561132 break;
8094
8095 case TANGOARR:
8096 {
8097 int32_t inx = (ri->d[rINDEX])/10000;
8098 if ( ((unsigned)inx) > 255 )
8099 {
8100 Z_scripterrlog("Invalid index %d supplied to Game->Tango[].\n", inx);
8101 ret = -10000;
8102 break;
8103 }
8104 else
8105 {
8106 ret=FFCore.TangoArray[inx]*10000;
8107 break;
8108 }
8109 }
8110 case GHOSTARR:
8111 {
8112 int32_t inx = (ri->d[rINDEX])/10000;
8113 if ( ((unsigned)inx) > 255 )
8114 {
8115 Z_scripterrlog("Invalid index %d supplied to Game->Ghost[].\n", inx);
8116 ret = -10000;
8117 break;
8118 }
8119 else
8120 {
8121 ret=FFCore.GhostArray[inx]*10000;
8122 break;
8123 }
8124 }
8125 case STDARR:
8126 {
8127 int32_t inx = (ri->d[rINDEX])/10000;
8128 if ( ((unsigned)inx) > 255 )
8129 {
8130 Z_scripterrlog("Invalid index %d supplied to Game->STD[].\n", inx);
8131 ret = -10000;
8132 break;
8133 }
8134 else
8135 {
8136 ret=FFCore.StdArray[inx]*10000;
8137 break;
8138 }
8139 }
8140
8141 case GAMEMISCSPR:
8142 {
8143 int32_t inx = (ri->d[rINDEX])/10000;
8144 if ( ((unsigned)inx) > sprMAX )
8145 {
8146 Z_scripterrlog("Invalid index %d supplied to Game->MiscSprites[].\n", inx);
8147 ret = -10000;
8148 }
8149 else
8150 {
8151 ret = QMisc.sprites[inx] * 10000;
8152 }
8153 break;
8154 }
8155 case GAMEMISCSFX:
8156 {
8157 int32_t inx = (ri->d[rINDEX])/10000;
8158 if ( ((unsigned)inx) > sfxMAX )
8159 {
8160 Z_scripterrlog("Invalid index %d supplied to Game->MiscSFX[].\n", inx);
8161 ret = -10000;
8162 }
8163 else
8164 {
8165 ret = QMisc.miscsfx[inx] * 10000;
8166 }
8167 break;
8168 }
8169 case GAMEEVENTDATA:
8170 {
8171 int32_t inx = (ri->d[rINDEX])/10000;
8172 ret = 0;
8173 if ( ((unsigned)inx) < FFCore.eventData.size() )
8174 {
8175 ret = FFCore.eventData[inx];
8176 }
8177 break;
8178 }
8179 case GAMEMOUSECURSOR:
8180 {
8181 ret = game_mouse_index*10000;
8182 break;
8183 }
8184 case GAMETRIGGROUPS:
8185 {
8186 int32_t ind = (ri->d[rINDEX])/10000;
8187 if(unsigned(ind)>255)
8188 Z_scripterrlog("Invalid index %d supplied to Game->TrigGroups[]\n",ind);
8189 ret = get_trig_group(ind)*10000;
8190 break;
8191 }
8192
8193 case GAMEGRAVITY:
8194 {
8195 int32_t indx = ri->d[rINDEX]/10000;
8196 if ( ((unsigned)indx) > 2 )
8197 //if(indx < 0 || indx > 2)
8198 {
8199 ret = -10000;
8200 Z_scripterrlog("Invalid index used to access Game->Gravity[]: %d\n", indx);
8201 }
8202 else
8203 {
8204 switch(indx)
8205 {
8206 case 0: //Gravity Strength
8207 ret = zinit.gravity2;
8208 break;
8209 case 1: //Terminal Velocity
8210 ret = zinit.terminalv * 100;
8211 break;
8212 case 2: //Sprite Layer Threshold
8213 ret = zinit.jump_hero_layer_threshold * 10000;
8214 break;
8215 }
8216 }
8217 break;
8218 }
8219
8220 case GAMESCROLLING:
8221 {
8222 191517 int32_t indx = ri->d[rINDEX]/10000;
8223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 191517 times.
191517 if ( ((unsigned)indx) >= SZ_SCROLLDATA )
8224 //if(indx < 0 || indx >= SZ_SCROLLDATA)
8225 {
8226 Z_scripterrlog("Invalid index used to access Game->Scrolling[]: %d\n", indx);
8227 }
8228 else
8229 {
8230 191517 ret = FFCore.ScrollingData[indx] * 10000L;
8231 }
8232 191517 break;
8233 }
8234
8235
8236 case SCREENSTATED:
8237 {
8238 1218351 int32_t mi = get_mi(MAPSCR_TEMP0);
8239
1/2
✓ Branch 0 taken 1218351 times.
✗ Branch 1 not taken.
1218351 if(mi<0) {ret = 0;break;}
8240 1218351 ret=((game->maps[mi]>>((ri->d[rINDEX]/10000)))&1)?10000:0;
8241 }
8242 1218351 break;
8243 case SCREENEXSTATED:
8244 {
8245 int32_t mi = get_mi(MAPSCR_TEMP0);
8246 if(mi<0) {ret = 0;break;}
8247 ret=((game->xstates[mi]>>((ri->d[rINDEX]/10000)))&1)?10000:0;
8248 }
8249 break;
8250 case SCREENLENSSHOWS:
8251 {
8252 int ind = ri->d[rINDEX]/10000;
8253 if(ind < 0 || ind > 6)
8254 Z_scripterrlog("Bad index Screen->LensShows[%d]\n",ind);
8255 else ret = (tmpscr->lens_show & (1<<ind)) ? 10000 : 0;
8256 break;
8257 }
8258 case SCREENLENSHIDES:
8259 {
8260 int ind = ri->d[rINDEX]/10000;
8261 if(ind < 0 || ind > 6)
8262 Z_scripterrlog("Bad index Screen->LensHides[%d]\n",ind);
8263 else ret = (tmpscr->lens_hide & (1<<ind)) ? 10000 : 0;
8264 break;
8265 }
8266
8267 case DISTANCE:
8268 {
8269 225833 double x1 = double(ri->d[rSFTEMP] / 10000.0);
8270 225833 double y1 = double(ri->d[rINDEX] / 10000.0);
8271 225833 double x2 = double(ri->d[rINDEX2] / 10000.0);
8272 225833 double y2 = double(ri->d[rEXP1] / 10000.0);
8273
8274
8275
8276 225833 int32_t result = FFCore.Distance(x1, y1, x2, y2);
8277 225833 ret = (result);
8278
8279 225833 break;
8280 }
8281 case LONGDISTANCE:
8282 {
8283 double x1 = double(ri->d[rSFTEMP]);
8284 double y1 = double(ri->d[rINDEX]);
8285 double x2 = double(ri->d[rINDEX2]);
8286 double y2 = double(ri->d[rEXP1]);
8287
8288
8289
8290 int32_t result = FFCore.LongDistance(x1, y1, x2, y2);
8291 ret = (result);
8292
8293 break;
8294 }
8295
8296 case DISTANCESCALE:
8297 {
8298 double x1 = (double)(ri->d[rSFTEMP] / 10000.0);
8299 zprint2("x1 is: %f\n", x1);
8300 double y1 = (double)(ri->d[rINDEX] / 10000.0);
8301 zprint2("y1 is: %f\n", y1);
8302 double x2 = (double)(ri->d[rINDEX2] / 10000.0);
8303 zprint2("x2 is: %f\n", x2);
8304 double y2 = (double)(ri->d[rEXP1] / 10000.0);
8305 zprint2("y2 is: %f\n", y2);
8306
8307 int32_t scale = (ri->d[rWHAT_NO_7]/10000);
8308 zprint2("Scale is: %d\n", scale);
8309
8310 if ( !scale ) scale = 10000;
8311 int32_t result = FFCore.Distance(x1, y1, x2, y2, scale);
8312 ret = (result);
8313
8314 break;
8315 }
8316 case LONGDISTANCESCALE:
8317 {
8318 double x1 = (double)(ri->d[rSFTEMP]);
8319 zprint2("x1 is: %f\n", x1);
8320 double y1 = (double)(ri->d[rINDEX]);
8321 zprint2("y1 is: %f\n", y1);
8322 double x2 = (double)(ri->d[rINDEX2]);
8323 zprint2("x2 is: %f\n", x2);
8324 double y2 = (double)(ri->d[rEXP1]);
8325 zprint2("y2 is: %f\n", y2);
8326
8327 int32_t scale = (ri->d[rWHAT_NO_7]);
8328 zprint2("Scale is: %d\n", scale);
8329
8330 if ( !scale ) scale = 1;
8331 int32_t result = FFCore.LongDistance(x1, y1, x2, y2, scale);
8332 ret = (result);
8333
8334 break;
8335 }
8336
8337 case SCREENSTATEDD:
8338 {
8339 // Gah! >:( Screen state is stored in game->maps, which uses 128 screens per map,
8340 // but the compiler multiplies the map number by 136, so it has to be corrected here.
8341 // Yeah, the compiler could be fixed, but that wouldn't cover existing quests...
8342 18739404 int32_t mi = ri->d[rINDEX] / 10000;
8343 18739404 mi -= 8*((ri->d[rINDEX] / 10000) / MAPSCRS);
8344
8345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18739404 times.
18739404 if(BC::checkMapID(mi>>7, "Game->GetScreenState") == SH::_NoError)
8346 18739404 ret=(game->maps[mi] >> (ri->d[rINDEX2] / 10000) & 1) ? 10000 : 0;
8347 else
8348 ret=0;
8349
8350 18739404 break;
8351 }
8352
8353 case GAMEGUYCOUNTD:
8354 ret=game->guys[(currmap * MAPSCRSNORMAL) + (ri->d[rINDEX] / 10000)]*10000;
8355 break;
8356
8357 case CURMAP:
8358 22550639 ret=(1+currmap)*10000;
8359 22550639 break;
8360
8361 case CURSCR:
8362 14110188 ret=currscr*10000;
8363 14110188 break;
8364
8365 case ALLOCATEBITMAPR:
8366 125 ret=FFCore.do_allocate_bitmap();
8367 125 break;
8368
8369 case GETMIDI:
8370 63717 ret=(currmidi-(ZC_MIDI_COUNT-1))*10000;
8371 63717 break;
8372
8373 case CURDSCR:
8374 {
8375 5919526 int32_t di = (get_currscr()-DMaps[get_currdmap()].xoff);
8376
2/2
✓ Branch 0 taken 3035425 times.
✓ Branch 1 taken 2884101 times.
5919526 ret=(DMaps[get_currdmap()].type==dmOVERW ? currscr : di)*10000;
8377 }
8378 5919526 break;
8379
8380 case GAMEMAXMAPS:
8381 ret = (map_count)*10000;
8382 break;
8383 case GAMENUMMESSAGES:
8384 ret = (msg_count-1) * 10000;
8385 break;
8386
8387 case CURDMAP:
8388 49182684 ret=currdmap*10000;
8389 49182684 break;
8390
8391 case CURLEVEL:
8392 14019927 ret=DMaps[get_currdmap()].level*10000;
8393 14019927 break;
8394
8395 case GAMECLICKFREEZE:
8396 ret=disableClickToFreeze?0:10000;
8397 break;
8398
8399
8400 case NOACTIVESUBSC:
8401 ret=Hero.stopSubscreenFalling()?10000:0;
8402 break;///----------------------------------------------------------------------------------------------------//
8403 //BottleTypes
8404 case BOTTLECOUNTER:
8405 {
8406 if(bottletype* ptr = checkBottleData(ri->bottletyperef, "Counter[]"))
8407 {
8408 int32_t indx = ri->d[rINDEX]/10000;
8409 if(unsigned(indx) > 2)
8410 {
8411 Z_scripterrlog("Invalid index %d supplied to bottledata->Counter[].\n", indx);
8412 ret = -10000L;
8413 break;
8414 }
8415 ret = 10000L * ptr->counter[indx];
8416 }
8417 else ret = -10000L;
8418 }
8419 break;
8420
8421 case BOTTLEAMOUNT:
8422 {
8423 if(bottletype* ptr = checkBottleData(ri->bottletyperef, "Amount[]"))
8424 {
8425 int32_t indx = ri->d[rINDEX]/10000;
8426 if(unsigned(indx) > 2)
8427 {
8428 Z_scripterrlog("Invalid index %d supplied to bottledata->Amount[].\n", indx);
8429 ret = -10000L;
8430 break;
8431 }
8432 ret = 10000L * ptr->amount[indx];
8433 }
8434 else ret = -10000L;
8435 }
8436 break;
8437
8438 case BOTTLEPERCENT:
8439 {
8440 if(bottletype* ptr = checkBottleData(ri->bottletyperef, "IsPercent[]"))
8441 {
8442 int32_t indx = ri->d[rINDEX]/10000;
8443 if(unsigned(indx) > 2)
8444 {
8445 Z_scripterrlog("Invalid index %d supplied to bottledata->IsPercent[].\n", indx);
8446 ret = -10000L;
8447 break;
8448 }
8449 ret = (ptr->flags & (1<<indx)) ? 10000L : 0;
8450 }
8451 else ret = -10000L;
8452 }
8453 break;
8454
8455 case BOTTLEFLAGS:
8456 {
8457 if(bottletype* ptr = checkBottleData(ri->bottletyperef, "Flags[]"))
8458 {
8459 int32_t indx = ri->d[rINDEX]/10000;
8460 if(unsigned(indx) > 3)
8461 {
8462 Z_scripterrlog("Invalid index %d supplied to bottledata->Flags[].\n", indx);
8463 ret = -10000L;
8464 break;
8465 }
8466 int32_t flag = 0;
8467 switch(indx)
8468 {
8469 case 0: flag = BTFLAG_AUTOONDEATH; break;
8470 case 1: flag = BTFLAG_ALLOWIFFULL; break;
8471 case 2: flag = BTFLAG_CURESWJINX; break;
8472 case 3: flag = BTFLAG_CUREITJINX; break;
8473 }
8474 ret = (ptr->flags & flag) ? 10000L : 0;
8475 }
8476 else ret = -10000L;
8477 }
8478 break;
8479
8480 case BOTTLENEXT:
8481 {
8482 if(bottletype* ptr = checkBottleData(ri->bottletyperef, "NextType"))
8483 {
8484 ret = 10000L * ptr->next_type;
8485 }
8486 else ret = -10000L;
8487 }
8488 break;
8489 ///----------------------------------------------------------------------------------------------------//
8490 //BottleShops
8491 case BSHOPFILL:
8492 {
8493 if(bottleshoptype* ptr = checkBottleShopData(ri->bottleshopref, "Fill[]"))
8494 {
8495 int32_t indx = ri->d[rINDEX]/10000;
8496 if(unsigned(indx) > 2)
8497 {
8498 Z_scripterrlog("Invalid index %d supplied to bottleshopdata->Fill[].\n", indx);
8499 ret = -10000L;
8500 break;
8501 }
8502 ret = 10000L * ptr->fill[indx];
8503 }
8504 else ret = -10000L;
8505 }
8506 break;
8507
8508 case BSHOPCOMBO:
8509 {
8510 if(bottleshoptype* ptr = checkBottleShopData(ri->bottleshopref, "Combo[]"))
8511 {
8512 int32_t indx = ri->d[rINDEX]/10000;
8513 if(unsigned(indx) > 2)
8514 {
8515 Z_scripterrlog("Invalid index %d supplied to bottleshopdata->Combo[].\n", indx);
8516 ret = -10000L;
8517 break;
8518 }
8519 ret = 10000L * ptr->comb[indx];
8520 }
8521 else ret = -10000L;
8522 }
8523 break;
8524
8525 case BSHOPCSET:
8526 {
8527 if(bottleshoptype* ptr = checkBottleShopData(ri->bottleshopref, "CSet[]"))
8528 {
8529 int32_t indx = ri->d[rINDEX]/10000;
8530 if(unsigned(indx) > 2)
8531 {
8532 Z_scripterrlog("Invalid index %d supplied to bottleshopdata->CSet[].\n", indx);
8533 ret = -10000L;
8534 break;
8535 }
8536 ret = 10000L * ptr->cset[indx];
8537 }
8538 else ret = -10000L;
8539 }
8540 break;
8541
8542 case BSHOPPRICE:
8543 {
8544 if(bottleshoptype* ptr = checkBottleShopData(ri->bottleshopref, "Price[]"))
8545 {
8546 int32_t indx = ri->d[rINDEX]/10000;
8547 if(unsigned(indx) > 2)
8548 {
8549 Z_scripterrlog("Invalid index %d supplied to bottleshopdata->Price[].\n", indx);
8550 ret = -10000L;
8551 break;
8552 }
8553 ret = 10000L * ptr->price[indx];
8554 }
8555 else ret = -10000L;
8556 }
8557 break;
8558
8559 case BSHOPSTR:
8560 {
8561 if(bottleshoptype* ptr = checkBottleShopData(ri->bottleshopref, "InfoString[]"))
8562 {
8563 int32_t indx = ri->d[rINDEX]/10000;
8564 if(unsigned(indx) > 2)
8565 {
8566 Z_scripterrlog("Invalid index %d supplied to bottleshopdata->InfoString[].\n", indx);
8567 ret = -10000L;
8568 break;
8569 }
8570 ret = 10000L * ptr->str[indx];
8571 }
8572 else ret = -10000L;
8573 }
8574 break;
8575
8576 ///----------------------------------------------------------------------------------------------------//
8577 //DMap Information
8578
8579 #define GET_DMAP_VAR(member, str) \
8580 { \
8581 int32_t ID = ri->d[rINDEX] / 10000; \
8582 if(BC::checkDMapID(ID, str) != SH::_NoError) \
8583 ret = -10000; \
8584 else \
8585 ret = DMaps[ID].member * 10000; \
8586 }
8587
8588 case DMAPFLAGSD:
8589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1764243 times.
1764243 GET_DMAP_VAR(flags, "Game->DMapFlags") break;
8590
8591 case DMAPLEVELD:
8592
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1019 times.
1019 GET_DMAP_VAR(level, "Game->DMapLevel") break;
8593
8594 case DMAPCOMPASSD:
8595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 255560 times.
255560 GET_DMAP_VAR(compass, "Game->DMapCompass") break;
8596
8597 case DMAPCONTINUED:
8598 GET_DMAP_VAR(cont, "Game->DMapContinue") break;
8599
8600 case DMAPLEVELPAL:
8601
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 741668 times.
741668 GET_DMAP_VAR(color, "Game->DMapPalette") break;
8602
8603 case DMAPOFFSET:
8604
1/2
✓ Branch 0 taken 95414 times.
✗ Branch 1 not taken.
95414 GET_DMAP_VAR(xoff, "Game->DMapOffset") break;
8605
8606 case DMAPMAP:
8607 {
8608 9482 int32_t ID = ri->d[rINDEX] / 10000;
8609
8610
1/2
✓ Branch 0 taken 9482 times.
✗ Branch 1 not taken.
9482 if(BC::checkDMapID(ID, "Game->DMapMap") != SH::_NoError)
8611 ret = -10000;
8612 else
8613 9482 ret = (DMaps[ID].map+1) * 10000;
8614
8615 9482 break;
8616 }
8617
8618 case DMAPMIDID:
8619 {
8620 37 int32_t ID = ri->d[rINDEX] / 10000;
8621
8622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if(BC::checkDMapID(ID, "Game->DMapMIDI") == SH::_NoError)
8623 {
8624 // Based on play_DmapMusic
8625
2/5
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
37 switch(DMaps[ID].midi)
8626 {
8627 case 2:
8628 ret = -60000;
8629 break; // Dungeon
8630
8631 case 3:
8632 ret = -30000;
8633 break; // Level 9
8634
8635 case 1:
8636 ret = -20000;
8637 break; // Overworld
8638
8639 case 0:
8640 4 ret = 0;
8641 4 break; // None
8642
8643 default:
8644 33 ret = (DMaps[ID].midi - 3) * 10000;
8645 33 }
8646 37 }
8647 else
8648 ret = -10000; // Which is valid, but whatever.
8649
8650 37 break;
8651 }
8652
8653 ///----------------------------------------------------------------------------------------------------//
8654 //Screen->ComboX
8655 #define GET_COMBO_VAR(member, str) \
8656 { \
8657 int32_t pos = ri->d[rINDEX] / 10000; \
8658 if(BC::checkComboPos(pos, str) != SH::_NoError) \
8659 { \
8660 ret = -10000; \
8661 } \
8662 else \
8663 ret = tmpscr->member[pos]*10000; \
8664 }
8665
8666 case COMBODD:
8667
1/2
✓ Branch 0 taken 27341446 times.
✗ Branch 1 not taken.
27341446 GET_COMBO_VAR(data, "Screen->ComboD[]") break;
8668
8669 case COMBOCD:
8670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2709583 times.
2709583 GET_COMBO_VAR(cset, "Screen->ComboC[]") break;
8671
8672 case COMBOFD:
8673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3906008 times.
3906008 GET_COMBO_VAR(sflag, "Screen->ComboF[]") break;
8674
8675 #define GET_COMBO_VAR_BUF(member, str) \
8676 { \
8677 int32_t pos = ri->d[rINDEX] / 10000; \
8678 if(BC::checkComboPos(pos, str) != SH::_NoError) \
8679 { \
8680 ret = -10000; \
8681 } \
8682 else \
8683 ret = combobuf[tmpscr->data[pos]].member * 10000; \
8684 }
8685
8686 case COMBOTD:
8687
1/2
✓ Branch 0 taken 26493201 times.
✗ Branch 1 not taken.
26493201 GET_COMBO_VAR_BUF(type, "Screen->ComboT[]") break;
8688
8689 case COMBOID:
8690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2974800 times.
2974800 GET_COMBO_VAR_BUF(flag, "Screen->ComboI[]") break;
8691
8692 case COMBOSD:
8693 {
8694 96784 int32_t pos = ri->d[rINDEX] / 10000;
8695
8696
2/2
✓ Branch 0 taken 95200 times.
✓ Branch 1 taken 1584 times.
96784 if(BC::checkComboPos(pos, "Screen->ComboS[]") != SH::_NoError)
8697 1584 ret = -10000;
8698 else
8699 95200 ret = (combobuf[tmpscr->data[pos]].walk & 0xF) * 10000;
8700 }
8701 96784 break;
8702
8703 case COMBOED:
8704 {
8705 int32_t pos = ri->d[rINDEX] / 10000;
8706
8707 if(BC::checkComboPos(pos, "Screen->ComboE[]") != SH::_NoError)
8708 ret = -10000;
8709 else
8710 ret = ((combobuf[tmpscr->data[pos]].walk & 0xF0)>>4) * 10000;
8711 }
8712 break;
8713
8714 ///----------------------------------------------------------------------------------------------------//
8715 //Game->GetComboX
8716
8717 case COMBODDM:
8718 {
8719 13758809 int32_t pos = (ri->d[rINDEX])/10000;
8720 13758809 int32_t sc = (ri->d[rEXP1]/10000);
8721 13758809 int32_t m = (ri->d[rINDEX2]/10000)-1;
8722
2/2
✓ Branch 0 taken 11881062 times.
✓ Branch 1 taken 1877747 times.
13758809 int32_t scr = zc_max(m*MAPSCRS+sc,0);
8723 13758809 int32_t layr = whichlayer(scr);
8724
8725
2/4
✓ Branch 0 taken 13758809 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13758809 times.
13758809 if(pos < 0 || pos >= 176)
8726 {
8727 Z_scripterrlog("Invalid combo position (%d) passed to GetComboData", pos);
8728 ret = -10000;
8729 }
8730
1/2
✓ Branch 0 taken 13758809 times.
✗ Branch 1 not taken.
13758809 else if(scr < 0)
8731 {
8732 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboData", scr);
8733 ret = -10000;
8734 }
8735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13758809 times.
13758809 else if(sc >= MAPSCRS)
8736 {
8737 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboData", sc);
8738 ret = -10000;
8739 }
8740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13758809 times.
13758809 else if(m >= map_count)
8741 {
8742 Z_scripterrlog("Invalid Map ID (%d) passed to GetComboData", m);
8743 ret = -10000;
8744 }
8745
2/2
✓ Branch 0 taken 11885286 times.
✓ Branch 1 taken 1873523 times.
13758809 else if(m < 0) ret = 0; //No layer present
8746
8747 //if(pos >= 0 && pos < 176 && scr >= 0 && sc < MAPSCRS && m < map_count)
8748 else
8749 {
8750
2/2
✓ Branch 0 taken 109146 times.
✓ Branch 1 taken 11776140 times.
11885286 if(scr==(currmap*MAPSCRS+currscr))
8751 109146 ret=tmpscr->data[pos]*10000;
8752
2/2
✓ Branch 0 taken 5826733 times.
✓ Branch 1 taken 5949407 times.
11776140 else if(layr>-1)
8753 5826733 ret=tmpscr2[layr].data[pos]*10000;
8754 5949407 else ret=TheMaps[scr].data[pos]*10000;
8755 }
8756
8757 }
8758 13758809 break;
8759
8760 case COMBOCDM:
8761 {
8762 2272124 int32_t pos = (ri->d[rINDEX])/10000;
8763 2272124 int32_t sc = (ri->d[rEXP1]/10000);
8764 2272124 int32_t m = (ri->d[rINDEX2]/10000)-1;
8765
1/2
✓ Branch 0 taken 2272124 times.
✗ Branch 1 not taken.
2272124 int32_t scr = zc_max(m*MAPSCRS+sc,0);
8766 2272124 int32_t layr = whichlayer(scr);
8767
8768
2/4
✓ Branch 0 taken 2272124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2272124 times.
2272124 if(pos < 0 || pos >= 176)
8769 {
8770 Z_scripterrlog("Invalid combo position (%d) passed to GetComboCSet", pos);
8771 ret = -10000;
8772 }
8773
1/2
✓ Branch 0 taken 2272124 times.
✗ Branch 1 not taken.
2272124 else if(scr < 0)
8774 {
8775 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboCSet", scr);
8776 ret = -10000;
8777 }
8778
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2272124 times.
2272124 else if(sc >= MAPSCRS)
8779 {
8780 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboCSet", sc);
8781 ret = -10000;
8782 }
8783
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2272124 times.
2272124 else if(m >= map_count)
8784 {
8785 Z_scripterrlog("Invalid Map ID (%d) passed to GetComboCSet", m);
8786 ret = -10000;
8787 }
8788
1/2
✓ Branch 0 taken 2272124 times.
✗ Branch 1 not taken.
2272124 else if(m < 0) ret = 0; //No layer present
8789
8790 //if(pos >= 0 && pos < 176 && scr >= 0 && sc < MAPSCRS && m < map_count)
8791 else
8792 {
8793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2272124 times.
2272124 if(scr==(currmap*MAPSCRS+currscr))
8794 ret=tmpscr->cset[pos]*10000;
8795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2272124 times.
2272124 else if(layr>-1)
8796 ret=tmpscr2[layr].cset[pos]*10000;
8797 2272124 else ret=TheMaps[scr].cset[pos]*10000;
8798 }
8799
8800 }
8801 2272124 break;
8802
8803 case COMBOFDM:
8804 {
8805 5866709 int32_t pos = (ri->d[rINDEX])/10000;
8806 5866709 int32_t sc = (ri->d[rEXP1]/10000);
8807 5866709 int32_t m = (ri->d[rINDEX2]/10000)-1;
8808
1/2
✓ Branch 0 taken 5866709 times.
✗ Branch 1 not taken.
5866709 int32_t scr = zc_max(m*MAPSCRS+sc,0);
8809 5866709 int32_t layr = whichlayer(scr);
8810
8811
3/4
✓ Branch 0 taken 5866709 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4000 times.
✓ Branch 3 taken 5862709 times.
5866709 if(pos < 0 || pos >= 176)
8812 {
8813 4000 Z_scripterrlog("Invalid combo position (%d) passed to GetComboFlag", pos);
8814 4000 ret = -10000;
8815 4000 }
8816
1/2
✓ Branch 0 taken 5862709 times.
✗ Branch 1 not taken.
5862709 else if(scr < 0)
8817 {
8818 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboFlag", scr);
8819 ret = -10000;
8820 }
8821
2/2
✓ Branch 0 taken 4212 times.
✓ Branch 1 taken 5858497 times.
5862709 else if(sc >= MAPSCRS)
8822 {
8823 4212 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboFlag", sc);
8824 4212 ret = -10000;
8825 4212 }
8826
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5858497 times.
5858497 else if(m >= map_count)
8827 {
8828 Z_scripterrlog("Invalid Map ID (%d) passed to GetComboFlag", m);
8829 ret = -10000;
8830 }
8831
1/2
✓ Branch 0 taken 5858497 times.
✗ Branch 1 not taken.
5858497 else if(m < 0) ret = 0; //No layer present
8832 //if(pos >= 0 && pos < 176 && scr >= 0 && sc < MAPSCRS && m < map_count)
8833 else
8834 {
8835
2/2
✓ Branch 0 taken 317735 times.
✓ Branch 1 taken 5540762 times.
5858497 if(scr==(currmap*MAPSCRS+currscr))
8836 317735 ret=tmpscr->sflag[pos]*10000;
8837
2/2
✓ Branch 0 taken 4629060 times.
✓ Branch 1 taken 911702 times.
5540762 else if(layr>-1)
8838 4629060 ret=tmpscr2[layr].sflag[pos]*10000;
8839 911702 else ret=TheMaps[scr].sflag[pos]*10000;
8840 }
8841
8842 }
8843 5866709 break;
8844
8845 case COMBOTDM:
8846 {
8847 449777 int32_t pos = (ri->d[rINDEX])/10000;
8848 449777 int32_t sc = (ri->d[rEXP1]/10000);
8849 449777 int32_t m = (ri->d[rINDEX2]/10000)-1;
8850
1/2
✓ Branch 0 taken 449777 times.
✗ Branch 1 not taken.
449777 int32_t scr = zc_max(m*MAPSCRS+sc,0);
8851 449777 int32_t layr = whichlayer(scr);
8852
8853
2/4
✓ Branch 0 taken 449777 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 449777 times.
449777 if(pos < 0 || pos >= 176)
8854 {
8855 Z_scripterrlog("Invalid combo position (%d) passed to GetComboType", pos);
8856 ret = -10000;
8857 }
8858
1/2
✓ Branch 0 taken 449777 times.
✗ Branch 1 not taken.
449777 else if(scr < 0)
8859 {
8860 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboType", scr);
8861 ret = -10000;
8862 }
8863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 449777 times.
449777 else if(sc >= MAPSCRS)
8864 {
8865 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboType", sc);
8866 ret = -10000;
8867 }
8868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 449777 times.
449777 else if(m >= map_count)
8869 {
8870 Z_scripterrlog("Invalid Map ID (%d) passed to GetComboType", m);
8871 ret = -10000;
8872 }
8873
1/2
✓ Branch 0 taken 449777 times.
✗ Branch 1 not taken.
449777 else if(m < 0) ret = 0; //No layer present
8874
8875 //if(pos >= 0 && pos < 176 && scr >= 0 && sc < MAPSCRS && m < map_count)
8876 else
8877 {
8878
2/2
✓ Branch 0 taken 106581 times.
✓ Branch 1 taken 343196 times.
449777 if(scr==(currmap*MAPSCRS+currscr))
8879 106581 ret=combobuf[tmpscr->data[pos]].type*10000;
8880
2/2
✓ Branch 0 taken 105393 times.
✓ Branch 1 taken 237803 times.
343196 else if(layr>-1)
8881 105393 ret=combobuf[tmpscr2[layr].data[pos]].type*10000;
8882 713409 else ret=combobuf[
8883 713409 TheMaps[scr].data[pos]].type*10000;
8884 }
8885 }
8886 449777 break;
8887
8888 case COMBOIDM:
8889 {
8890 421915 int32_t pos = (ri->d[rINDEX])/10000;
8891 421915 int32_t sc = (ri->d[rEXP1]/10000);
8892 421915 int32_t m = (ri->d[rINDEX2]/10000)-1;
8893
1/2
✓ Branch 0 taken 421915 times.
✗ Branch 1 not taken.
421915 int32_t scr = zc_max(m*MAPSCRS+sc,0);
8894 421915 int32_t layr = whichlayer(scr);
8895
8896
3/4
✓ Branch 0 taken 421915 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4000 times.
✓ Branch 3 taken 417915 times.
421915 if(pos < 0 || pos >= 176)
8897 {
8898 4000 Z_scripterrlog("Invalid combo position (%d) passed to GetComboInherentFlag", pos);
8899 4000 ret = -10000;
8900 4000 }
8901
1/2
✓ Branch 0 taken 417915 times.
✗ Branch 1 not taken.
417915 else if(scr < 0)
8902 {
8903 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboInherentFlag", scr);
8904 ret = -10000;
8905 }
8906
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 417915 times.
417915 else if(sc >= MAPSCRS)
8907 {
8908 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboInherentFlag", sc);
8909 ret = -10000;
8910 }
8911
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 417915 times.
417915 else if(m >= map_count)
8912 {
8913 Z_scripterrlog("Invalid Map ID (%d) passed to GetComboInherentFlag", m);
8914 ret = -10000;
8915 }
8916
1/2
✓ Branch 0 taken 417915 times.
✗ Branch 1 not taken.
417915 else if(m < 0) ret = 0; //No layer present
8917
8918 //if(pos >= 0 && pos < 176 && scr >= 0 && sc < MAPSCRS && m < map_count)
8919 else
8920 {
8921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 417915 times.
417915 if(scr==(currmap*MAPSCRS+currscr))
8922 ret=combobuf[tmpscr->data[pos]].flag*10000;
8923
1/2
✓ Branch 0 taken 417915 times.
✗ Branch 1 not taken.
417915 else if(layr>-1)
8924 417915 ret=combobuf[tmpscr2[layr].data[pos]].flag*10000;
8925 else ret=combobuf[TheMaps[scr].data[pos]].flag*10000;
8926 }
8927 }
8928 421915 break;
8929
8930 case COMBOSDM:
8931 {
8932 6342577 int32_t pos = (ri->d[rINDEX])/10000;
8933 6342577 int32_t sc = (ri->d[rEXP1]/10000);
8934 6342577 int32_t m = (ri->d[rINDEX2]/10000)-1;
8935
2/2
✓ Branch 0 taken 6341872 times.
✓ Branch 1 taken 705 times.
6342577 int32_t scr = zc_max(m*MAPSCRS+sc,0);
8936 6342577 int32_t layr = whichlayer(scr);
8937
8938
2/4
✓ Branch 0 taken 6342577 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6342577 times.
6342577 if(pos < 0 || pos >= 176)
8939 {
8940 Z_scripterrlog("Invalid combo position (%d) passed to GetComboSolid", pos);
8941 ret = -10000;
8942 }
8943
1/2
✓ Branch 0 taken 6342577 times.
✗ Branch 1 not taken.
6342577 else if(scr < 0)
8944 {
8945 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboSolid", scr);
8946 ret = -10000;
8947 }
8948
2/2
✓ Branch 0 taken 2106 times.
✓ Branch 1 taken 6340471 times.
6342577 else if(sc >= MAPSCRS)
8949 {
8950 2106 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboSolid", sc);
8951 2106 ret = -10000;
8952 2106 }
8953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6340471 times.
6340471 else if(m >= map_count)
8954 {
8955 Z_scripterrlog("Invalid Map ID (%d) passed to GetComboSolid", m);
8956 ret = -10000;
8957 }
8958
2/2
✓ Branch 0 taken 6339767 times.
✓ Branch 1 taken 704 times.
6340471 else if(m < 0) ret = 0; //No layer present
8959
8960 //if(pos >= 0 && pos < 176 && scr >= 0 && sc < MAPSCRS && m < map_count)
8961 else
8962 {
8963
2/2
✓ Branch 0 taken 581032 times.
✓ Branch 1 taken 5758735 times.
6339767 if(scr==(currmap*MAPSCRS+currscr))
8964 581032 ret=(combobuf[tmpscr->data[pos]].walk&15)*10000;
8965
2/2
✓ Branch 0 taken 644433 times.
✓ Branch 1 taken 5114302 times.
5758735 else if(layr>-1)
8966 644433 ret=(combobuf[tmpscr2[layr].data[pos]].walk&15)*10000;
8967 5114302 else ret=(combobuf[TheMaps[scr].data[pos]].walk&15)*10000;
8968 }
8969
8970 }
8971 6342577 break;
8972
8973
8974
8975
8976 ///----------------------------------------------------------------------------------------------------//
8977 //Screen Information
8978
8979 #define GET_SCREENDATA_VAR_INT32(member, str) \
8980 { \
8981 ret = (tmpscr->member *10000); \
8982 } \
8983
8984 #define GET_SCREENDATA_VAR_INT16(member, str) \
8985 { \
8986 ret = (tmpscr->member *10000); \
8987 } \
8988
8989 #define GET_SCREENDATA_VAR_BYTE(member, str) \
8990 { \
8991 ret = (tmpscr->member *10000); \
8992 } \
8993
8994 #define GET_SCREENDATA_VAR_INDEX32(member, str, indexbound) \
8995 { \
8996 int32_t indx = ri->d[rINDEX] / 10000; \
8997 ret = (tmpscr->member[indx] *10000); \
8998 } \
8999
9000 #define GET_SCREENDATA_VAR_INDEX16(member, str, indexbound) \
9001 { \
9002 int32_t indx = ri->d[rINDEX] / 10000; \
9003 ret = (tmpscr->member[indx] *10000); \
9004 } \
9005
9006 #define GET_SCREENDATA_BYTE_INDEX(member, str, indexbound) \
9007 { \
9008 int32_t indx = ri->d[rINDEX] / 10000; \
9009 ret = (tmpscr->member[indx] *10000); \
9010 } \
9011
9012 //byte
9013 #define GET_SCREENDATA_LAYER_INDEX(member, str, indexbound) \
9014 { \
9015 int32_t indx = ri->d[rINDEX] / 10000; \
9016 if ( FFCore.quest_format[vFFScript] < 11 ) ++indx; \
9017 if(indx < 1 || indx > indexbound ) \
9018 { \
9019 Z_scripterrlog("Invalid Index passed to Screen->%s[]: %d\n", str, indx); \
9020 ret = -10000; \
9021 } \
9022 else \
9023 { \
9024 ret = (tmpscr->member[indx-1] *10000); \
9025 } \
9026 } \
9027
9028
9029 #define GET_SCREENDATA_BOOL_INDEX(member, str, indexbound) \
9030 { \
9031 int32_t indx = ri->d[rINDEX] / 10000; \
9032 if(indx < 0 || indx > indexbound ) \
9033 { \
9034 Z_scripterrlog("Invalid Index passed to Screen->%s[]: %d\n", (indx), str); \
9035 ret = -10000; \
9036 } \
9037 else \
9038 { \
9039 ret = (tmpscr->member[indx]?10000:0); \
9040 } \
9041 } \
9042
9043 #define GET_FFC_BOOL_INDEX(member, str, indexbound) \
9044 { \
9045 int32_t indx = ri->d[rINDEX] / 10000; \
9046 if(indx < 0 || indx > indexbound ) \
9047 { \
9048 Z_scripterrlog("Invalid Index passed to Screen->%s[]: %d\n", (indx), str); \
9049 ret = -10000; \
9050 } \
9051 else \
9052 { \
9053 ret = (tmpscr->ffcs[indx].member?10000:0); \
9054 } \
9055 } \
9056
9057
9058 #define GET_SCREENDATA_FLAG(member, str, indexbound) \
9059 { \
9060 int32_t flag = (value/10000); \
9061 ret = (tmpscr->member&flag) ? 10000 : 0); \
9062 } \
9063
9064 case SCREENDATAVALID: GET_SCREENDATA_VAR_BYTE(valid, "Valid"); break; //b
9065 case SCREENDATAGUY: GET_SCREENDATA_VAR_BYTE(guy, "Guy"); break; //b
9066 case SCREENDATASTRING: GET_SCREENDATA_VAR_INT32(str, "String"); break; //w
9067 case SCREENDATAROOM: GET_SCREENDATA_VAR_BYTE(room, "RoomType"); break; //b
9068 case SCREENDATAITEM:
9069 {
9070 if(tmpscr->hasitem)
9071 ret = (tmpscr->item *10000);
9072 else ret = -10000;
9073 break;
9074 }
9075 case SCREENDATAHASITEM: GET_SCREENDATA_VAR_BYTE(hasitem, "HasItem"); break; //b
9076 case SCREENDATATILEWARPTYPE: GET_SCREENDATA_BYTE_INDEX(tilewarptype, "TileWarpType", 3); break; //b, 4 of these
9077 //case SCREENDATATILEWARPOVFLAGS: GET_SCREENDATA_VAR_BYTE(tilewarpoverlayflags, "TileWarpOverlayFlags"); break; //b, tilewarpoverlayflags
9078 case SCREENDATADOORCOMBOSET: GET_SCREENDATA_VAR_INT32(door_combo_set, "DoorComboSet"); break; //w
9079 case SCREENDATAWARPRETX: GET_SCREENDATA_BYTE_INDEX(warpreturnx, "WarpReturnX", 3); break; //b, 4 of these
9080 case SCREENDATAWARPRETY: GET_SCREENDATA_BYTE_INDEX(warpreturny, "WarpReturnY", 3); break; //b, 4 of these
9081 case SCREENDATAWARPRETURNC: GET_SCREENDATA_VAR_INT32(warpreturnc, "WarpReturnC"); break; //w
9082 case SCREENDATASTAIRX: GET_SCREENDATA_VAR_BYTE(stairx, "StairsX"); break; //b
9083 case SCREENDATASTAIRY: GET_SCREENDATA_VAR_BYTE(stairy, "StairsY"); break; //b
9084 case SCREENDATAITEMX: GET_SCREENDATA_VAR_BYTE(itemx, "ItemX"); break; //itemx
9085 case SCREENDATAITEMY: GET_SCREENDATA_VAR_BYTE(itemy, "ItemY"); break; //itemy
9086 case SCREENDATACOLOUR: GET_SCREENDATA_VAR_INT32(color, "CSet"); break; //w
9087 case SCREENDATAENEMYFLAGS: GET_SCREENDATA_VAR_BYTE(enemyflags, "EnemyFlags"); break; //b
9088 case SCREENDATADOOR: GET_SCREENDATA_BYTE_INDEX(door, "Door", 3); break; //b, 4 of these
9089 case SCREENDATATILEWARPDMAP: GET_SCREENDATA_VAR_INDEX32(tilewarpdmap, "TileWarpDMap", 3); break; //w, 4 of these
9090 case SCREENDATATILEWARPSCREEN: GET_SCREENDATA_BYTE_INDEX(tilewarpscr, "TileWarpScreen", 3); break; //b, 4 of these
9091 case SCREENDATAEXITDIR: GET_SCREENDATA_VAR_BYTE(exitdir, "ExitDir"); break; //b
9092 case SCREENDATAENEMY: GET_SCREENDATA_VAR_INDEX32(enemy, "Enemy", 9); break; //w, 10 of these
9093 case SCREENDATAPATTERN: GET_SCREENDATA_VAR_BYTE(pattern, "Pattern"); break; //b
9094 case SCREENDATASIDEWARPTYPE: GET_SCREENDATA_BYTE_INDEX(sidewarptype, "SideWarpType", 3); break; //b, 4 of these
9095 //case SCREENDATASIDEWARPOVFLAGS: GET_SCREENDATA_VAR_BYTE(sidewarpoverlayflags, "SideWarpOverlayFlags"); break; //b
9096 case SCREENDATAWARPARRIVALX: GET_SCREENDATA_VAR_BYTE(warparrivalx, "WarpArrivalX"); break; //b
9097 case SCREENDATAWARPARRIVALY: GET_SCREENDATA_VAR_BYTE(warparrivaly, "WarpArrivalY"); break; //b
9098 case SCREENDATAPATH: GET_SCREENDATA_BYTE_INDEX(path, "MazePath", 3); break; //b, 4 of these
9099 case SCREENDATASIDEWARPSC: GET_SCREENDATA_BYTE_INDEX(sidewarpscr, "SideWarpScreen", 3); break; //b, 4 of these
9100 case SCREENDATASIDEWARPDMAP: GET_SCREENDATA_VAR_INDEX32(sidewarpdmap, "SideWarpDMap", 3); break; //w, 4 of these
9101 case SCREENDATASIDEWARPINDEX: GET_SCREENDATA_VAR_BYTE(sidewarpindex, "SideWarpIndex"); break; //b
9102 case SCREENDATAUNDERCOMBO: GET_SCREENDATA_VAR_INT32(undercombo, "Undercombo"); break; //w
9103 case SCREENDATAUNDERCSET: GET_SCREENDATA_VAR_BYTE(undercset, "UnderCSet"); break; //b
9104 case SCREENDATACATCHALL: GET_SCREENDATA_VAR_INT32(catchall, "Catchall"); break; //W
9105
9106 case SCREENDATACSENSITIVE: GET_SCREENDATA_VAR_BYTE(csensitive, "CSensitive"); break; //B
9107 case SCREENDATANORESET: GET_SCREENDATA_VAR_INT32(noreset, "NoReset"); break; //W
9108 case SCREENDATANOCARRY: GET_SCREENDATA_VAR_INT32(nocarry, "NoCarry"); break; //W
9109 case SCREENDATALAYERMAP: GET_SCREENDATA_LAYER_INDEX(layermap, "LayerMap", 6); break; //B, 6 OF THESE
9110 case SCREENDATALAYERSCREEN: GET_SCREENDATA_LAYER_INDEX(layerscreen, "LayerScreen", 6); break; //B, 6 OF THESE
9111 case SCREENDATALAYEROPACITY: GET_SCREENDATA_LAYER_INDEX(layeropacity, "LayerOpacity", 6); break; //B, 6 OF THESE
9112 case SCREENDATALAYERINVIS:
9113 {
9114 int32_t indx = ri->d[rINDEX] / 10000;
9115 if(indx < 0 || indx > 6 )
9116 {
9117 Z_scripterrlog("Invalid Index passed to Screen->LayerInvisible[]: %d\n", indx);
9118 ret = 0;
9119 }
9120 else
9121 {
9122 ret = ((tmpscr->hidelayers >> indx) & 1) *10000;
9123 }
9124 break;
9125 }
9126 case SCREENDATASCRIPTDRAWS:
9127 {
9128 int32_t indx = ri->d[rINDEX] / 10000;
9129 if(indx < 0 || indx > 7 )
9130 {
9131 Z_scripterrlog("Invalid Index passed to Screen->HideScriptLayer[]: %d\n", indx);
9132 ret = 0;
9133 }
9134 else
9135 {
9136 ret = ((tmpscr->hidescriptlayers >> indx) & 1) ? 0 : 10000;
9137 }
9138 break;
9139 }
9140 case SCREENDATATIMEDWARPTICS: GET_SCREENDATA_VAR_INT32(timedwarptics, "TimedWarpTimer"); break; //W
9141 case SCREENDATANEXTMAP: GET_SCREENDATA_VAR_BYTE(nextmap, "NextMap"); break; //B
9142 case SCREENDATANEXTSCREEN: GET_SCREENDATA_VAR_BYTE(nextscr, "NextScreen"); break; //B
9143 109824 case SCREENDATASECRETCOMBO: GET_SCREENDATA_VAR_INDEX32(secretcombo, "SecretCombo", 127); break; //W, 128 OF THESE
9144 case SCREENDATASECRETCSET: GET_SCREENDATA_BYTE_INDEX(secretcset, "SecretCSet", 127); break; //B, 128 OF THESE
9145 case SCREENDATASECRETFLAG: GET_SCREENDATA_BYTE_INDEX(secretflag, "SecretFlags", 127); break; //B, 128 OF THESE
9146 case SCREENDATAVIEWX: break;//GET_SCREENDATA_VAR_INT32(viewX, "ViewX"); break; //W
9147 case SCREENDATAVIEWY: break;//GET_SCREENDATA_VAR_INT32(viewY, "ViewY"); break; //W
9148 case SCREENDATASCREENWIDTH: break;//GET_SCREENDATA_VAR_BYTE(scrWidth, "Width"); break; //B
9149 case SCREENDATASCREENHEIGHT: break;//GET_SCREENDATA_VAR_BYTE(scrHeight, "Height"); break; //B
9150 case SCREENDATAENTRYX: GET_SCREENDATA_VAR_BYTE(entry_x, "EntryX"); break; //B
9151 case SCREENDATAENTRYY: GET_SCREENDATA_VAR_BYTE(entry_y, "EntryY"); break; //B
9152 //Number of ffcs that are in use (have valid data
9153 case SCREENDATANUMFF:
9154 {
9155 uint32_t indx = ri->d[rINDEX] / 10000;
9156 if (!indx || indx > MAXFFCS)
9157 {
9158 Z_scripterrlog("Invalid Index passed to Screen->NumFFCs[%d].\n Valid indices are 1 through %d.\n", indx, MAXFFCS);
9159 ret = 0;
9160 }
9161 else
9162 {
9163 --indx;
9164 ret = (tmpscr->ffcs[indx].getData() != 0) ? 10000 : 0;
9165 }
9166 break;
9167 }
9168 //inita //INT32, 32 OF THESE, EACH WITH 2
9169 case SCREENDATAFFINITIALISED: {
9170 int32_t indx = ri->d[rINDEX] / 10000;
9171 if (indx < 0 || indx > MAXFFCS-1)
9172 {
9173 Z_scripterrlog("Invalid Index passed to Screen->%s[]: %d\n", indx, "FFCRunning");
9174 ret = -10000;
9175 }
9176 else
9177 {
9178 ret = get_script_engine_data(ScriptType::FFC, indx).initialized ? 10000 : 0;
9179 }
9180 }
9181 break;
9182
9183 case SCREENDATASCRIPTENTRY: GET_SCREENDATA_VAR_INT32(script_entry, "ScriptEntry"); break; //W
9184 case SCREENDATASCRIPTOCCUPANCY: GET_SCREENDATA_VAR_INT32(script_occupancy, "ScriptOccupancy"); break;//W
9185 case SCREENDATASCRIPTEXIT: GET_SCREENDATA_VAR_INT32(script_exit, "ExitScript"); break; //W
9186 case SCREENDATAOCEANSFX: GET_SCREENDATA_VAR_BYTE(oceansfx, "OceanSFX"); break; //B
9187 case SCREENDATABOSSSFX: GET_SCREENDATA_VAR_BYTE(bosssfx, "BossSFX"); break; //B
9188 1 case SCREENDATASECRETSFX: GET_SCREENDATA_VAR_BYTE(secretsfx, "SecretSFX"); break; //B
9189 case SCREENDATAHOLDUPSFX: GET_SCREENDATA_VAR_BYTE(holdupsfx, "ItemSFX"); break; //B
9190 case SCREENDATASCREENMIDI:
9191 {
9192 ret = ((tmpscr->screen_midi+(MIDIOFFSET_MAPSCR-MIDIOFFSET_ZSCRIPT)) *10000);
9193 break;
9194 }
9195 case SCREENDATALENSLAYER: GET_SCREENDATA_VAR_BYTE(lens_layer, "LensLayer"); break; //B, OLD QUESTS ONLY?
9196
9197 case SCREENSIDEWARPID:
9198 {
9199 int32_t indx = ri->d[rINDEX] / 10000;
9200
9201 ret = (((tmpscr->flags2 >> indx) & 1)
9202 ? (tmpscr->sidewarpindex >> (2*indx)) & 3 //Return which warp is set
9203 : -1 //Returns -1 if no warp is set
9204 )*10000;
9205 break;
9206 }
9207
9208 case SCREENDATATILEWARPOVFLAGS:
9209 {
9210 int32_t indx = ri->d[rINDEX] / 10000;
9211 if ( ((unsigned)indx) > 3 )
9212 {
9213 Z_scripterrlog("Invalid index passed to TileWarpOverlayFlags[%d].\n. Valid indices are [0] through [3].\n", indx);
9214 ret = 0;
9215 }
9216 else
9217 {
9218 ret = (tmpscr->tilewarpoverlayflags & (1<<indx))?10000:0;
9219 }
9220 break;
9221 }
9222
9223 case SCREENDATASIDEWARPOVFLAGS:
9224 {
9225 int32_t indx = ri->d[rINDEX] / 10000;
9226 if ( ((unsigned)indx) > 3 )
9227 {
9228 Z_scripterrlog("Invalid index passed to SideWarpOverlayFlags[%d].\n. Valid indices are [0] through [3].\n", indx);
9229 ret = 0;
9230 }
9231 else
9232 {
9233 ret = (tmpscr->sidewarpoverlayflags & (1<<indx))?10000:0;
9234 }
9235 break;
9236 }
9237
9238 case SCREENDATATWARPRETSQR:
9239 {
9240 int32_t indx = ri->d[rINDEX] / 10000;
9241 if ( ((unsigned)indx) > 3)
9242 {
9243 ret = -10000;
9244 Z_scripterrlog("Invalid Array Index passed to Screen->TileWarpReturnSquare[]: %d\n", indx);
9245
9246 }
9247 else
9248 {
9249 ret = ((tmpscr->warpreturnc>>(indx*2))&3) * 10000;
9250 }
9251 break;
9252 }
9253
9254
9255 case SCREENDATASWARPRETSQR:
9256 {
9257 int32_t indx = ri->d[rINDEX] / 10000;
9258 if ( ((unsigned)indx) > 3)
9259 {
9260 ret = -10000;
9261 Z_scripterrlog("Invalid Array Index passed to Screen->SideWarpReturnSquare[]: %d\n", indx);
9262
9263 }
9264 else
9265 {
9266 ret = ((tmpscr->warpreturnc>>(8+(indx*2)))&3) * 10000;
9267 }
9268 break;
9269 }
9270
9271 case SCREENDATAFLAGS:
9272 {
9273 int32_t flagid = (ri->d[rINDEX])/10000;
9274 //bool valtrue = ( value ? 10000 : 0);
9275 switch(flagid)
9276 {
9277 case 0: ret = (tmpscr->flags * 10000); break;
9278 case 1: ret = (tmpscr->flags2 * 10000); break;
9279 case 2: ret = (tmpscr->flags3 * 10000); break;
9280 case 3: ret = (tmpscr->flags4 * 10000); break;
9281 case 4: ret = (tmpscr->flags5 * 10000); break;
9282 case 5: ret = (tmpscr->flags6 * 10000); break;
9283 case 6: ret = (tmpscr->flags7 * 10000); break;
9284 case 7: ret = (tmpscr->flags8 * 10000); break;
9285 case 8: ret = (tmpscr->flags9 * 10000); break;
9286 case 9: ret = (tmpscr->flags10 * 10000); break;
9287 default:
9288 {
9289 Z_scripterrlog("Invalid index passed to mapdata->flags[]: %d\n", flagid);
9290 ret = -10000;
9291 break;
9292
9293 }
9294 }
9295 break;
9296 //GET_SCREENDATA_BYTE_INDEX //B, 11 OF THESE, flags, flags2-flags10
9297 }
9298
9299 case SCREENSECRETSTRIGGERED:
9300 {
9301 910 ret = triggered_screen_secrets ? 10000L : 0L;
9302 910 break;
9303 }
9304
9305 case SHOWNMSG:
9306 {
9307 ret = ((msg_active || msg_onscreen) ? msgstr : 0) * 10000L;
9308 break;
9309 }
9310
9311 case SDD:
9312 {
9313
2/2
✓ Branch 0 taken 387442 times.
✓ Branch 1 taken 2580 times.
390022 int32_t di = ((get_currdmap())<<7) + get_currscr()-(DMaps[get_currdmap()].type==dmOVERW ? 0 : DMaps[get_currdmap()].xoff);
9314 390022 ret=FFScript::get_screen_d(di, ri->d[rINDEX]/10000);
9315 }
9316 390022 break;
9317
9318 case SDDD:
9319 43250 ret=FFScript::get_screen_d((ri->d[rINDEX])/10000 + ((get_currdmap())<<7), ri->d[rINDEX2] / 10000);
9320 43250 break;
9321
9322 case LINKOTILE:
9323 ret=FFCore.getHeroOTile(ri->d[rINDEX]/10000, ri->d[rINDEX2] / 10000);
9324 break;
9325
9326 case SDDDD:
9327 3 ret=FFScript::get_screen_d(ri->d[rINDEX2] / 10000 + ((ri->d[rINDEX]/10000)<<7), ri->d[rEXP1] / 10000);
9328 3 break;
9329
9330 case SCRDOORD:
9331 4 ret=tmpscr->door[ri->d[rINDEX]/10000]*10000;
9332 4 break;
9333
9334 case SCREENSCRIPT:
9335 ret=tmpscr->script*10000;
9336 break;
9337
9338 case SCREENINITD:
9339 ret = tmpscr->screeninitd[ri->d[rINDEX]/10000];
9340 break;
9341
9342 case MAPDATAINITDARRAY:
9343 {
9344 if ( ri->mapsref == MAX_SIGNED_32 )
9345 {
9346 Z_scripterrlog("Script attempted to use a mapdata->InitD[%d] on a pointer that is uninitialised\n",ri->d[rINDEX]/10000);
9347 break;
9348 }
9349 else
9350 {
9351 mapscr *m = GetMapscr(ri->mapsref);
9352 ret = m->screeninitd[ri->d[rINDEX]/10000];
9353 }
9354 break;
9355 }
9356
9357 case MAPDATALAYERINVIS:
9358 {
9359 int32_t indx = ri->d[rINDEX] / 10000;
9360 if(indx < 0 || indx > 6 )
9361 {
9362 Z_scripterrlog("Invalid Index passed to mapdata->LayerInvisible[]: %d\n", indx);
9363 ret = 0;
9364 }
9365 else
9366 {
9367 if ( ri->mapsref == MAX_SIGNED_32 )
9368 {
9369 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","LayerInvisible");
9370 ret = -10000;
9371 }
9372 else
9373 {
9374 mapscr *m = GetMapscr(ri->mapsref);
9375 ret = ((m->hidelayers >> indx) & 1) *10000;
9376 }
9377 }
9378 break;
9379 }
9380 case MAPDATASCRIPTDRAWS:
9381 {
9382 int32_t indx = ri->d[rINDEX] / 10000;
9383 if(indx < 0 || indx > 7 )
9384 {
9385 Z_scripterrlog("Invalid Index passed to mapdata->DisableScriptDraws[]: %d\n", indx);
9386 ret = 0;
9387 }
9388 else
9389 {
9390 if ( ri->mapsref == MAX_SIGNED_32 )
9391 {
9392 Z_scripterrlog("Script attempted to use a mapdata->DisableScriptDraws on a pointer that is uninitialised\n");
9393 ret = -10000;
9394 }
9395 else
9396 {
9397 mapscr *m = GetMapscr(ri->mapsref);
9398 ret = ((m->hidescriptlayers >> indx) & 1) ? 0 : 10000;
9399 }
9400 }
9401 break;
9402 }
9403
9404 //These use the same method as GetScreenD -Z
9405 case SCREENWIDTH:
9406 // ret=FFScript::get_screenWidth(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9407 break;
9408
9409 case SCREENHEIGHT:
9410 // ret=FFScript::get_screenHeight(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9411 break;
9412
9413 case SCREENVIEWX:
9414 // ret=get_screenViewX(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9415 break;
9416
9417 case SCREENVIEWY:
9418 // ret=get_screenViewY(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9419 break;
9420
9421 case SCREENGUY:
9422 ret=get_screenGuy(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9423 break;
9424
9425 case SCREENSTRING:
9426 ret=get_screenString(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9427 break;
9428
9429 case SCREENROOM:
9430 ret=get_screenRoomtype(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9431 break;
9432
9433 case SCREENENTX:
9434 ret=get_screenEntryX(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9435 break;
9436
9437 case SCREENENTY:
9438 ret=get_screenEntryY(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9439 break;
9440
9441 case SCREENITEM:
9442 ret=get_screenitem(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9443 break;
9444
9445 case SCREENUNDCMB:
9446 ret=get_screenundercombo(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9447 break;
9448
9449 case SCREENUNDCST:
9450 ret=get_screenundercset(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9451 break;
9452
9453 case SCREENCATCH:
9454 ret=get_screenatchall(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)]);
9455 break;
9456
9457
9458 case LIT:
9459 10246 ret= darkroom ? 0 : 10000;
9460 10246 break;
9461
9462 case WAVY:
9463 7214 ret = wavy*10000;
9464 7214 break;
9465
9466 case QUAKE:
9467 2272 ret = quakeclk*10000;
9468 2272 break;
9469
9470 case SCREENFLAGSD:
9471 6637215 ret = get_screenflags(tmpscr,vbound(ri->d[rINDEX] / 10000,0,9));
9472 6637215 break;
9473
9474 case SCREENEFLAGSD:
9475 1522143 ret = get_screeneflags(tmpscr,vbound(ri->d[rINDEX] / 10000,0,2));
9476 1522143 break;
9477
9478 case NPCCOUNT:
9479 11315120 ret = guys.Count()*10000;
9480 11315120 break;
9481
9482 case ROOMDATA:
9483 ret = tmpscr->catchall*10000;
9484 break;
9485
9486 case ROOMTYPE:
9487 ret = tmpscr->room*10000;
9488 break;
9489
9490 case PUSHBLOCKX:
9491
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 229459 times.
229611 ret = blockmoving ? int32_t(mblock2.x)*10000 : -10000;
9492 229611 break;
9493
9494 case PUSHBLOCKY:
9495
1/2
✓ Branch 0 taken 91 times.
✗ Branch 1 not taken.
91 ret = blockmoving ? int32_t(mblock2.y)*10000 : -10000;
9496 91 break;
9497
9498 case PUSHBLOCKLAYER:
9499 ret = blockmoving ? int32_t(mblock2.blockLayer)*10000 : -10000;
9500 break;
9501
9502 case PUSHBLOCKCOMBO:
9503 ret = mblock2.bcombo*10000;
9504 break;
9505
9506 case PUSHBLOCKCSET:
9507 ret = mblock2.cs*10000;
9508 break;
9509
9510 case UNDERCOMBO:
9511 1 ret = tmpscr->undercombo*10000;
9512 1 break;
9513
9514 case UNDERCSET:
9515 1 ret = tmpscr->undercset*10000;
9516 1 break;
9517
9518 //Creates an lweapon using an iemdata struct values to generate its properties.
9519 //Useful in conjunction with the new weapon editor.
9520 case CREATELWPNDX:
9521 {
9522 //Z_message("Trying to get Player->SetExtend().\n");
9523 int32_t ID = (ri->d[rINDEX] / 10000);
9524 int32_t itemid = (ri->d[rINDEX2]/10000);
9525 itemid = vbound(itemid,0,(MAXITEMS-1));
9526
9527 //Z_scripterrlog("GetHeroExtend rid->[2] is (%i), trying to use for '%s'\n", ri->d[rEXP1], "ri->d[rEXP1]");
9528 //Z_scripterrlog("GetHeroExtend rid->[1] is (%i), trying to use for '%s'\n", state, "state");
9529 //Z_scripterrlog("GetHeroExtend rid->[0] is (%i), trying to use for '%s'\n", dir, "dir");
9530 if ( Lwpns.Count() < 256 )
9531 {
9532
9533 Lwpns.add
9534 (
9535 new weapon
9536 (
9537 (zfix)0, /*X*/
9538 (zfix)0, /*Y*/
9539 (zfix)0, /*Z*/
9540 ID, /*id*/
9541 0, /*type*/
9542 0, /*power*/
9543 0, /*dir*/
9544 -1, /*Parentid*/
9545 Hero.getUID(), /*prntid*/
9546 false, /*isdummy*/
9547 1, /*script_gen*/
9548 1, /*islwpn*/
9549 (ID==wWind?1:0) /*special*/
9550 )
9551 );
9552 ri->lwpn = Lwpns.spr(Lwpns.Count() - 1)->getUID();
9553
9554 weapon *w = (weapon*)Lwpns.spr(Lwpns.Count()-1); //last created
9555 //w->LOADGFX(FFCore.getDefWeaponSprite(ID)); //What the fuck Zoria, this broke old quests...
9556 w->ScriptGenerated = 1;
9557 w->isLWeapon = 1;
9558 if(ID == wWind) w->specialinfo = 1;
9559 //weapon *w = (weapon*)Lwpns.spr(Lwpns.Count()-1); //last created
9560 //w->LOADGFX(FFCore.getDefWeaponSprite(ID)); //not needed here because this has access to wpn->prent
9561 }
9562 else
9563 {
9564 Z_scripterrlog("Tried to create too many LWeapons on the screen. The current LWeapon count is: %d\n", Lwpns.Count());
9565 ri->lwpn = 0;
9566 }
9567
9568 /* Z_scripterrlog("CreateLWeaponDx ri->d[rINDEX] is (%i), trying to use for '%s'\n", ID, "ID");
9569 Z_scripterrlog("CreateLWeaponDx ri->d[rINDEX2] is (%i), trying to use for '%s'\n", itemid, "itemid");
9570 Z_scripterrlog("CreateLWeaponDx ri->lwpn is (%i), trying to use for '%s'\n", ri->lwpn, "ri->lwpn"); */
9571
9572 ret = ri->lwpn;
9573 }
9574 break;
9575
9576 /*
9577 //Screen->CollisionDx(int32_t enemy_index, int32_t lweapon_type, int32_t power, int32_t x, int32_t y, int32_t weapon_dir, int32_t parent_item);
9578 //Handles collision between an npc at screen index 'enemy_index', and an arbitrary lweapon that may or may not exist.
9579 //Does damage, and returns true a value collision is valid. Returns a different value otherwise.
9580
9581 // take damage or ignore it
9582 // -1: damage (if any) dealt
9583 // 1: blocked
9584 // 0: weapon passes through unhindered
9585 // 2: heal enemy? -ZoriaRPG
9586
9587 //THis function should automatically check for shields blocking the weapon, and calculate enemy defences.
9588 //In theory, scritped swords, and other melee weapons could use this, as coudl any weapon, and it may simplify
9589 //collision routines.
9590 case COLLISIONDX:
9591 {
9592 //Z_message("Trying to get Player->SetExtend().\n");
9593 int32_t index = (ri->d[rINDEX] / 10000);
9594 int32_t lweapon_type = (ri->d[rINDEX2] / 10000);
9595 int32_t power = (ri->d[rEXP1]/10000);
9596
9597 int32_t wpnx = ri->4[3]/10000, wpny = ri->d[rSFRAME]/10000;
9598 int32_t dir = ri->d[rNUL]/10000;
9599 int32_t parentitem = (ri->d[rSFTEMP]/10000);
9600 lweapon_type = vbound(lweapon_type,0,40); //Are we at 40, or higher now>
9601 parentitem = vbound(itemid,0,255);
9602
9603 //Log the stack events:
9604 Z_scripterrlog("CollisionDx ri->d[rINDEX] is (%i), trying to use for '%s'\n", index, "index");
9605 Z_scripterrlog("CollisionDx ri->d[rINDEX2] is (%i), trying to use for '%s'\n", lweapon_type, "lweapon_type");
9606 Z_scripterrlog("CollisionDx ri->d[rEXP1] is (%i), trying to use for '%s'\n", power, "power");
9607 Z_scripterrlog("CollisionDx ri->d[rEXP2] is (%i), trying to use for '%s'\n", wpnx, "wpnx");
9608 Z_scripterrlog("CollisionDx ri->d[rSFRAME] is (%i), trying to use for '%s'\n", wpny, "wpny");
9609 Z_scripterrlog("CollisionDx ri->d[rNUL] is (%i), trying to use for '%s'\n", dir, "dir");
9610 Z_scripterrlog("CollisionDx ri->d[rINDEX] is (%i), trying to use for '%s'\n", parentitem, "parentitem");
9611
9612 weapon *w = new weapon((zfix)wpnx,(zfix)wpny,(zfix)0,lweapon_type,0,power,dir,parentitem,-1,false);
9613 int32_t retval = ((enemy*)guys.spr(index))->takehit(w);
9614 //TakeHit, as I recall, applies damage and returns the hit status. Gold.
9615 delete w;
9616 ret = retval;
9617 }
9618 break;
9619
9620 */
9621 case DEBUGREFFFC:
9622 {
9623 int32_t r = -1;
9624 if ( ri->ffcref ) r = ri->ffcref;
9625 ret = r * 10000;
9626 break;
9627 }
9628
9629 case DEBUGREFITEM:
9630 {
9631 int32_t r = -1;
9632 if ( ri->itemref ) r = ri->itemref;
9633 ret = r * 10000;
9634 break;
9635 }
9636
9637 case DEBUGREFITEMDATA:
9638 {
9639 int32_t r = -1;
9640 if ( ri->idata ) r = ri->idata;
9641 ret = r * 10000;
9642 break;
9643 }
9644
9645 case DEBUGREFLWEAPON:
9646 {
9647 int32_t r = -1;
9648 if ( ri->lwpn ) r = ri->lwpn;
9649 ret = r * 10000;
9650 break;
9651 }
9652
9653 case DEBUGREFEWEAPON:
9654 {
9655 int32_t r = -1;
9656 if ( ri->ewpn ) r = ri->ewpn;
9657 ret = r * 10000;
9658 break;
9659 }
9660
9661 case DEBUGREFNPC:
9662 {
9663 int32_t r = -1;
9664 if ( ri->guyref ) r = ri->guyref;
9665 ret = r * 10000;
9666 break;
9667 }
9668
9669 case DEBUGSP:
9670 {
9671 ret = SH::read_stack(ri->sp) * 10000;
9672 break;
9673 }
9674 case DEBUGGDR:
9675 {
9676 int32_t a = vbound(ri->d[rINDEX]/10000,0,15);
9677 int32_t r = -1;
9678 if ( game->global_d[a] ) r = game->global_d[a];
9679 ret = r * 10000;
9680 break;
9681 }
9682
9683 ///----------------------------------------------------------------------------------------------------//
9684 //New Datatype Variables
9685
9686 ///----------------------------------------------------------------------------------------------------//
9687 //spritedata sp-> Variables
9688
9689 case SPRITEDATATILE: GET_SPRITEDATA_VAR_INT(tile, "Tile") break;
9690 case SPRITEDATAMISC: GET_SPRITEDATA_VAR_INT(misc, "Misc") break;
9691 case SPRITEDATACSETS:
9692 {
9693 if(unsigned(ri->spritesref) > (MAXWPNS-1) )
9694 {
9695 ret = -10000;
9696 Z_scripterrlog("Invalid Sprite ID passed to spritedata->CSet: %d\n", (ri->spritesref*10000));
9697 }
9698 else
9699 ret = ((wpnsbuf[ri->spritesref].csets & 0xF) * 10000);
9700 break;
9701 }
9702 case SPRITEDATAFLCSET:
9703 {
9704 if(unsigned(ri->spritesref) > (MAXWPNS-1) )
9705 {
9706 ret = -10000;
9707 Z_scripterrlog("Invalid Sprite ID passed to spritedata->%s: %d\n", (ri->spritesref*10000), "FlashCSet");
9708 break;
9709 }
9710 ret = (((wpnsbuf[ri->spritesref].csets & 0xF0)>>4) * 10000);
9711 break;
9712 }
9713 case SPRITEDATAFRAMES: GET_SPRITEDATA_VAR_INT(frames, "Frames") break;
9714 case SPRITEDATASPEED: GET_SPRITEDATA_VAR_INT(speed, "Speed") break;
9715 case SPRITEDATATYPE: GET_SPRITEDATA_VAR_INT(type, "Type") break;
9716 case SPRITEDATAFLAGS:
9717 {
9718 if(unsigned(ri->spritesref) > (MAXWPNS-1) )
9719 {
9720 ret = 0;
9721 Z_scripterrlog("Invalid Sprite ID passed to spritedata->Flags[]: %d\n", (ri->spritesref*10000));
9722 break;
9723 }
9724 int32_t index = ri->d[rINDEX]/10000;
9725 if(unsigned(index) >= 5)
9726 {
9727 ret = 0;
9728 Z_scripterrlog("Invalid index passed to spritedata->Flags[]: %d\n", index);
9729 break;
9730 }
9731 ret = (wpnsbuf[ri->spritesref].misc & (1<<index)) ? 10000 : 0;
9732 break;
9733 }
9734 case SPRITEDATAID:
9735 {
9736 if(unsigned(ri->spritesref) > (MAXWPNS-1) )
9737 {
9738 ret = -10000;
9739 Z_scripterrlog("Invalid Sprite ID passed to spritedata->ID: %d\n", (ri->spritesref*10000));
9740 break;
9741 }
9742 ret = ri->spritesref*10000;
9743 break;
9744 }
9745
9746 ///----------------------------------------------------------------------------------------------------//
9747 //mapdata m-> variables
9748 #define GET_MAPDATA_VAR_INT32(member, str) \
9749 { \
9750 if ( mapscr *m = GetMapscr(ri->mapsref) ) \
9751 { \
9752 ret = (m->member *10000); \
9753 } \
9754 else \
9755 { \
9756 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
9757 ret = -10000; \
9758 } \
9759 } \
9760
9761 #define GET_MAPDATA_VAR_INT16(member, str) \
9762 { \
9763 if ( mapscr *m = GetMapscr(ri->mapsref) ) \
9764 { \
9765 ret = (m->member *10000); \
9766 } \
9767 else \
9768 { \
9769 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
9770 ret = -10000; \
9771 } \
9772 } \
9773
9774 #define GET_MAPDATA_VAR_BYTE(member, str) \
9775 { \
9776 if ( mapscr *m = GetMapscr(ri->mapsref) ) \
9777 { \
9778 ret = (m->member *10000); \
9779 } \
9780 else \
9781 { \
9782 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
9783 ret = -10000; \
9784 } \
9785 } \
9786
9787 #define GET_MAPDATA_VAR_INDEX32(member, str, indexbound) \
9788 { \
9789 int32_t indx = ri->d[rINDEX] / 10000; \
9790 if(indx < 0 || indx > indexbound ) \
9791 { \
9792 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
9793 ret = -10000; \
9794 } \
9795 else \
9796 { \
9797 if (mapscr *m = GetMapscr(ri->mapsref)) \
9798 { \
9799 ret = (m->member[indx] *10000); \
9800 } \
9801 else \
9802 { \
9803 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
9804 ret = -10000; \
9805 } \
9806 } \
9807 } \
9808
9809 #define GET_MAPDATA_VAR_INDEX16(member, str, indexbound) \
9810 { \
9811 int32_t indx = ri->d[rINDEX] / 10000; \
9812 if(indx < 0 || indx > indexbound ) \
9813 { \
9814 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
9815 ret = -10000; \
9816 } \
9817 else \
9818 { \
9819 if (mapscr *m = GetMapscr(ri->mapsref)) \
9820 { \
9821 ret = (m->member[indx] *10000); \
9822 } \
9823 else \
9824 { \
9825 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
9826 ret = -10000; \
9827 } \
9828 } \
9829 } \
9830
9831 #define GET_MAPDATA_BYTE_INDEX(member, str, indexbound) \
9832 { \
9833 int32_t indx = ri->d[rINDEX] / 10000; \
9834 if(indx < 0 || indx > indexbound ) \
9835 { \
9836 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
9837 ret = -10000; \
9838 } \
9839 else \
9840 { \
9841 if (mapscr *m = GetMapscr(ri->mapsref)) \
9842 { \
9843 ret = (m->member[indx] *10000); \
9844 } \
9845 else \
9846 { \
9847 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
9848 ret = -10000; \
9849 } \
9850 } \
9851 } \
9852
9853 /*
9854 #define GET_MAPDATA_LAYER_INDEX(member, str, indexbound) \
9855 { \
9856 int32_t indx = ri->d[rINDEX] / 10000; \
9857 mapscr *m = GetMapscr(ri->mapsref); \
9858 if ( indx == 0 ) \
9859 { \
9860 \
9861 } \
9862 else \
9863 { \
9864 ret = (m->member[indx-1] *10000); \
9865 } \
9866 } \
9867 */
9868
9869 #define GET_MAPDATA_LAYER_INDEX(member, str, indexbound) \
9870 { \
9871 int32_t indx = ri->d[rINDEX] / 10000; \
9872 if ( FFCore.quest_format[vFFScript] < 11 ) ++indx; \
9873 if(indx < 1 || indx > indexbound ) \
9874 { \
9875 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
9876 ret = -10000; \
9877 } \
9878 else \
9879 { \
9880 if (mapscr *m = GetMapscr(ri->mapsref)) \
9881 { \
9882 ret = (m->member[indx-1] *10000); \
9883 } \
9884 else \
9885 { \
9886 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
9887 ret = -10000; \
9888 } \
9889 } \
9890 } \
9891
9892 #define GET_MAPDATA_BOOL_INDEX(member, str, indexbound) \
9893 { \
9894 int32_t indx = ri->d[rINDEX] / 10000; \
9895 if(indx < 0 || indx > indexbound ) \
9896 { \
9897 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
9898 ret = -10000; \
9899 } \
9900 else \
9901 { \
9902 if (mapscr *m = GetMapscr(ri->mapsref)) \
9903 { \
9904 ret = (m->member[indx]?10000:0); \
9905 } \
9906 else \
9907 { \
9908 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
9909 ret = -10000; \
9910 } \
9911 } \
9912 } \
9913
9914 #define GET_FFC_MAPDATA_BOOL_INDEX(member, str, indexbound) \
9915 { \
9916 int32_t indx = ri->d[rINDEX] / 10000; \
9917 if(indx < 0 || indx > indexbound ) \
9918 { \
9919 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
9920 ret = -10000; \
9921 } \
9922 else \
9923 { \
9924 if (mapscr *m = GetMapscr(ri->mapsref)) \
9925 { \
9926 ret = (m->ffcs[indx].member?10000:0); \
9927 } \
9928 else \
9929 { \
9930 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
9931 ret = -10000; \
9932 } \
9933 } \
9934 } \
9935
9936 #define GET_MAPDATA_FLAG(member, str) \
9937 { \
9938 int32_t flag = (value/10000); \
9939 if (mapscr *m = GetMapscr(ri->mapsref)) \
9940 { \
9941 ret = (m->member&flag) ? 10000 : 0); \
9942 } \
9943 else \
9944 { \
9945 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
9946 ret = -10000; \
9947 } \
9948 } \
9949
9950 #define GET_SCREENDATA_COMBO_VAR(member, str) \
9951 { \
9952 if (mapscr *m = GetMapscr(ri->mapsref)) \
9953 { \
9954 int32_t pos = ri->d[rINDEX] / 10000; \
9955 if(BC::checkComboPos(pos, str) != SH::_NoError) \
9956 ret = -10000; \
9957 else \
9958 ret = m->member[pos]*10000; \
9959 } \
9960 else \
9961 { \
9962 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
9963 ret = -10000; \
9964 } \
9965 } \
9966
9967 #define GET_MAPDATA_COMBO_VAR_BUF(member, str) \
9968 { \
9969 if (mapscr *m = GetMapscr(ri->mapsref)) \
9970 { \
9971 int32_t pos = ri->d[rINDEX] / 10000; \
9972 if(BC::checkComboPos(pos, str) != SH::_NoError) \
9973 ret = -10000; \
9974 else \
9975 ret = combobuf[m->data[pos]].member * 10000; \
9976 } \
9977 else \
9978 { \
9979 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
9980 ret = -10000; \
9981 } \
9982 } \
9983
9984 #define GET_MAPDATA_FFCPOS_INDEX32(member, str, indexbound) \
9985 { \
9986 int32_t indx = (ri->d[rINDEX] / 10000)-1; \
9987 if(indx < 0 || indx > indexbound ) \
9988 { \
9989 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", (indx+1), str); \
9990 ret = -10000; \
9991 } \
9992 else if (mapscr *m = GetMapscr(ri->mapsref)) \
9993 { \
9994 ret = (m->ffcs[indx].member).getZLong(); \
9995 } \
9996 else \
9997 { \
9998 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","str"); \
9999 ret = -10000; \
10000 } \
10001 } \
10002
10003 #define GET_MAPDATA_FFC_INDEX32(member, str, indexbound) \
10004 { \
10005 int32_t indx = (ri->d[rINDEX] / 10000)-1; \
10006 if(indx < 0 || indx > indexbound ) \
10007 { \
10008 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", (indx+1), str); \
10009 ret = -10000; \
10010 } \
10011 else if (mapscr *m = GetMapscr(ri->mapsref)) \
10012 { \
10013 ret = (m->ffcs[indx].member)*10000; \
10014 } \
10015 else \
10016 { \
10017 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","str"); \
10018 ret = -10000; \
10019 } \
10020 } \
10021
10022 #define GET_MAPDATA_FFC_INDEX32(member, str, indexbound) \
10023 { \
10024 int32_t indx = (ri->d[rINDEX] / 10000)-1; \
10025 if(indx < 0 || indx > indexbound ) \
10026 { \
10027 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", (indx+1), str); \
10028 ret = -10000; \
10029 } \
10030 else if (mapscr *m = GetMapscr(ri->mapsref)) \
10031 { \
10032 ret = (m->ffcs[indx].member)*10000; \
10033 } \
10034 else \
10035 { \
10036 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","str"); \
10037 ret = -10000; \
10038 } \
10039 } \
10040
10041 case LOADMAPDATA:
10042 6509791 ret=FFScript::loadMapData();
10043 6509791 break;
10044
10045 case NPCCOLLISION:
10046 ret=FFCore.npc_collision();
10047 break;
10048
10049 case NPCLINEDUP:
10050 ret=FFCore.npc_linedup();
10051 break;
10052
10053 case CREATEBITMAP:
10054 {
10055 146 ret=FFCore.do_create_bitmap();
10056 146 break;
10057 }
10058
10059
10060 case MAPDATAVALID: GET_MAPDATA_VAR_BYTE(valid, "Valid"); break; //b
10061 case MAPDATAGUY: GET_MAPDATA_VAR_BYTE(guy, "Guy"); break; //b
10062 case MAPDATASTRING: GET_MAPDATA_VAR_INT32(str, "String"); break; //w
10063 case MAPDATAROOM: GET_MAPDATA_VAR_BYTE(room, "RoomType"); break; //b
10064 case MAPDATAITEM:
10065 {
10066 if ( mapscr *m = GetMapscr(ri->mapsref) )
10067 {
10068 if(m->hasitem)
10069 ret = (m->item *10000);
10070 else ret = -10000;
10071 }
10072 else
10073 {
10074 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","Item"); \
10075 ret = -10000;
10076 }
10077 break;
10078 }
10079 case MAPDATAHASITEM: GET_MAPDATA_VAR_BYTE(hasitem, "HasItem"); break; //b
10080 case MAPDATATILEWARPTYPE: GET_MAPDATA_BYTE_INDEX(tilewarptype, "TileWarpType", 3); break; //b, 4 of these
10081 //case MAPDATATILEWARPOVFLAGS: GET_MAPDATA_VAR_BYTE(tilewarpoverlayflags, "TileWarpOverlayFlags"); break; //b, tilewarpoverlayflags
10082 case MAPDATADOORCOMBOSET: GET_MAPDATA_VAR_INT32(door_combo_set, "DoorComboSet"); break; //w
10083 case MAPDATAWARPRETX: GET_MAPDATA_BYTE_INDEX(warpreturnx, "WarpReturnX", 3); break; //b, 4 of these
10084 case MAPDATAWARPRETY: GET_MAPDATA_BYTE_INDEX(warpreturny, "WarpReturnY", 3); break; //b, 4 of these
10085 case MAPDATAWARPRETURNC: GET_MAPDATA_VAR_INT32(warpreturnc, "WarpReturnC"); break; //w
10086 case MAPDATASTAIRX: GET_MAPDATA_VAR_BYTE(stairx, "StairsX"); break; //b
10087 case MAPDATASTAIRY: GET_MAPDATA_VAR_BYTE(stairy, "StairsY"); break; //b
10088 case MAPDATAITEMX: GET_MAPDATA_VAR_BYTE(itemx, "ItemX"); break; //itemx
10089 case MAPDATAITEMY: GET_MAPDATA_VAR_BYTE(itemy, "ItemY"); break; //itemy
10090 case MAPDATACOLOUR: GET_MAPDATA_VAR_INT32(color, "CSet"); break; //w
10091 case MAPDATAENEMYFLAGS: GET_MAPDATA_VAR_BYTE(enemyflags, "EnemyFlags"); break; //b
10092 case MAPDATADOOR: GET_MAPDATA_BYTE_INDEX(door, "Door", 3); break; //b, 4 of these
10093 case MAPDATATILEWARPDMAP: GET_MAPDATA_VAR_INDEX32(tilewarpdmap, "TileWarpDMap", 3); break; //w, 4 of these
10094 case MAPDATATILEWARPSCREEN: GET_MAPDATA_BYTE_INDEX(tilewarpscr, "TileWarpScreen", 3); break; //b, 4 of these
10095 case MAPDATAEXITDIR: GET_MAPDATA_VAR_BYTE(exitdir, "ExitDir"); break; //b
10096 case MAPDATAENEMY: GET_MAPDATA_VAR_INDEX32(enemy, "Enemy", 9); break; //w, 10 of these
10097 case MAPDATAPATTERN: GET_MAPDATA_VAR_BYTE(pattern, "Pattern"); break; //b
10098 case MAPDATASIDEWARPTYPE: GET_MAPDATA_BYTE_INDEX(sidewarptype, "SideWarpType", 3); break; //b, 4 of these
10099 //case MAPDATASIDEWARPOVFLAGS: GET_MAPDATA_VAR_BYTE(sidewarpoverlayflags, "SideWarpOverlayFlags"); break; //b
10100 case MAPDATAWARPARRIVALX: GET_MAPDATA_VAR_BYTE(warparrivalx, "WarpArrivalX"); break; //b
10101 case MAPDATAWARPARRIVALY: GET_MAPDATA_VAR_BYTE(warparrivaly, "WarpArrivalY"); break; //b
10102 case MAPDATAPATH: GET_MAPDATA_BYTE_INDEX(path, "MazePath", 3); break; //b, 4 of these
10103 case MAPDATASIDEWARPSC: GET_MAPDATA_BYTE_INDEX(sidewarpscr, "SideWarpScreen", 3); break; //b, 4 of these
10104 case MAPDATAINITD: GET_MAPDATA_VAR_INDEX32(screeninitd, "InitD", 8); break; //w, 4 of these
10105 case MAPDATASIDEWARPDMAP: GET_MAPDATA_VAR_INDEX32(sidewarpdmap, "SideWarpDMap", 3); break; //w, 4 of these
10106 case MAPDATASIDEWARPINDEX: GET_MAPDATA_VAR_BYTE(sidewarpindex, "SideWarpIndex"); break; //b
10107 case MAPDATAUNDERCOMBO: GET_MAPDATA_VAR_INT32(undercombo, "UnderCombo"); break; //w
10108 case MAPDATAUNDERCSET: GET_MAPDATA_VAR_BYTE(undercset, "UnderCSet"); break; //b
10109 case MAPDATACATCHALL: GET_MAPDATA_VAR_INT32(catchall, "Catchall"); break; //W
10110
10111 case MAPDATACSENSITIVE: GET_MAPDATA_VAR_BYTE(csensitive, "CSensitive"); break; //B
10112 case MAPDATANORESET: GET_MAPDATA_VAR_INT32(noreset, "NoReset"); break; //W
10113 case MAPDATANOCARRY: GET_MAPDATA_VAR_INT32(nocarry, "NoCarry"); break; //W
10114
4/8
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
12 case MAPDATALAYERMAP: GET_MAPDATA_LAYER_INDEX(layermap, "LayerMap", 6); break; //B, 6 OF THESE
10115
4/8
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
12 case MAPDATALAYERSCREEN: GET_MAPDATA_LAYER_INDEX(layerscreen, "LayerScreen", 6); break; //B, 6 OF THESE
10116 case MAPDATALAYEROPACITY: GET_MAPDATA_LAYER_INDEX(layeropacity, "LayerOpacity", 6); break; //B, 6 OF THESE
10117 case MAPDATATIMEDWARPTICS: GET_MAPDATA_VAR_INT32(timedwarptics, "TimedWarpTimer"); break; //W
10118 case MAPDATANEXTMAP: GET_MAPDATA_VAR_BYTE(nextmap, "NextMap"); break; //B
10119 case MAPDATANEXTSCREEN: GET_MAPDATA_VAR_BYTE(nextscr, "NextScreen"); break; //B
10120
3/6
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 128 times.
✓ Branch 4 taken 128 times.
✗ Branch 5 not taken.
256 case MAPDATASECRETCOMBO: GET_MAPDATA_VAR_INDEX32(secretcombo, "SecretCombo", 127); break; //W, 128 OF THESE
10121
3/6
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 128 times.
✓ Branch 4 taken 128 times.
✗ Branch 5 not taken.
256 case MAPDATASECRETCSET: GET_MAPDATA_BYTE_INDEX(secretcset, "SecretCSet", 127); break; //B, 128 OF THESE
10122
3/6
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 128 times.
✓ Branch 4 taken 128 times.
✗ Branch 5 not taken.
256 case MAPDATASECRETFLAG: GET_MAPDATA_BYTE_INDEX(secretflag, "SecretFlags", 127); break; //B, 128 OF THESE
10123
10124 case MAPDATAVIEWX: break;//GET_MAPDATA_VAR_INT32(viewX, "ViewX"); break; //W
10125 case MAPDATASCRIPT: GET_MAPDATA_VAR_INT32(script, "Script"); break; //W
10126 case MAPDATAVIEWY: break;//GET_MAPDATA_VAR_INT32(viewY, "ViewY"); break; //W
10127 case MAPDATASCREENWIDTH: break;//GET_MAPDATA_VAR_BYTE(scrWidth, "Width"); break; //B
10128 case MAPDATASCREENHEIGHT: break;//GET_MAPDATA_VAR_BYTE(scrHeight, "Height"); break; //B
10129 case MAPDATAENTRYX: GET_MAPDATA_VAR_BYTE(entry_x, "EntryX"); break; //B
10130 case MAPDATAENTRYY: GET_MAPDATA_VAR_BYTE(entry_y, "EntryY"); break; //B
10131
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
10 case MAPDATAFFDATA: GET_MAPDATA_FFC_INDEX32(getData(), "FFCData", MAXFFCS-1); break; //W, MAXFFCS OF THESE
10132
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
10 case MAPDATAFFCSET: GET_MAPDATA_FFC_INDEX32(cset, "FFCCSet", MAXFFCS-1); break; //B, MAXFFCS
10133
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
10 case MAPDATAFFDELAY: GET_MAPDATA_FFC_INDEX32(delay, "FFCDelay", MAXFFCS-1); break; //W, MAXFFCS
10134
3/6
✓ Branch 0 taken 389 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 389 times.
✓ Branch 4 taken 389 times.
✗ Branch 5 not taken.
778 case MAPDATAFFX: GET_MAPDATA_FFCPOS_INDEX32(x, "FFCX", MAXFFCS-1); break; //INT32, MAXFFCS OF THESE
10135
3/6
✓ Branch 0 taken 389 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 389 times.
✓ Branch 4 taken 389 times.
✗ Branch 5 not taken.
778 case MAPDATAFFY: GET_MAPDATA_FFCPOS_INDEX32(y, "FFCY", MAXFFCS-1); break; //..
10136
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
10 case MAPDATAFFXDELTA: GET_MAPDATA_FFCPOS_INDEX32(vx, "FFCVx", MAXFFCS-1); break; //..
10137
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
10 case MAPDATAFFYDELTA: GET_MAPDATA_FFCPOS_INDEX32(vy, "FFCVy", MAXFFCS-1); break; //..
10138
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
10 case MAPDATAFFXDELTA2: GET_MAPDATA_FFCPOS_INDEX32(ax, "FFCAx", MAXFFCS-1); break; //..
10139
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
10 case MAPDATAFFYDELTA2: GET_MAPDATA_FFCPOS_INDEX32(ay, "FFCAy", MAXFFCS-1); break; //..
10140
3/6
✓ Branch 0 taken 70 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 70 times.
✓ Branch 4 taken 70 times.
✗ Branch 5 not taken.
140 case MAPDATAFFFLAGS: GET_MAPDATA_FFC_INDEX32(flags, "FFCFlags", MAXFFCS-1); break; //INT16, MAXFFCS OF THESE
10141 case MAPDATASIDEWARPID:
10142 {
10143 int32_t indx = ri->d[rINDEX] / 10000;
10144 if (mapscr *m = GetMapscr(ri->mapsref))
10145 {
10146 ret = (((m->flags2 >> indx) & 1)
10147 ? (m->sidewarpindex >> (2*indx)) & 3 //Return which warp is set
10148 : -1 //Returns -1 if no warp is set
10149 )*10000;
10150 }
10151 else
10152 {
10153 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","SideWarpID");
10154 ret = -10000;
10155 }
10156 break;
10157 }
10158 //Number of ffcs that are in use (have valid data
10159 case MAPDATANUMFF:
10160 {
10161 32 uint32_t indx = ri->d[rINDEX] / 10000;
10162
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
32 if (!indx || indx > MAXFFCS)
10163 {
10164 Z_scripterrlog("Invalid Index passed to mapdata->NumFFCs[%d].\n Valid indices are 1 through %d.\n", indx, MAXFFCS);
10165 ret = 0;
10166 }
10167
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 else if (mapscr *m = GetMapscr(ri->mapsref))
10168 {
10169 32 --indx;
10170 32 ret = (m->ffcs[indx].getData() != 0) ? 10000 : 0;
10171 32 }
10172 else
10173 {
10174 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","NumFFCs[]");
10175 ret = 0;
10176 }
10177 32 break;
10178 }
10179
10180 case MAPDATATILEWARPOVFLAGS:
10181 {
10182 int32_t indx = ri->d[rINDEX] / 10000;
10183 if ( ((unsigned)indx) > 3 )
10184 {
10185 Z_scripterrlog("Invalid index passed to TileWarpOverlayFlags[%d].\n. Valid indices are [0] through [3].\n", indx);
10186 ret = 0;
10187 }
10188 else if (mapscr *m = GetMapscr(ri->mapsref))
10189 {
10190 ret = (m->tilewarpoverlayflags & (1<<indx))?10000:0;
10191 }
10192 else
10193 {
10194 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","NumFFCs[]");
10195 ret = 0;
10196 }
10197 break;
10198 }
10199
10200 case MAPDATASIDEWARPOVFLAGS:
10201 {
10202 int32_t indx = ri->d[rINDEX] / 10000;
10203 if ( ((unsigned)indx) > 3 )
10204 {
10205 Z_scripterrlog("Invalid index passed to SideWarpOverlayFlags[%d].\n. Valid indices are [0] through [3].\n", indx);
10206 ret = 0;
10207 }
10208 else if (mapscr *m = GetMapscr(ri->mapsref))
10209 {
10210 ret = (m->sidewarpoverlayflags & (1<<indx))?10000:0;
10211 }
10212 else
10213 {
10214 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","NumFFCs[]");
10215 ret = 0;
10216 }
10217 break;
10218 }
10219
10220 case MAPDATATWARPRETSQR:
10221 {
10222 int32_t indx = ri->d[rINDEX] / 10000;
10223 if ( ((unsigned)indx) > 3)
10224 {
10225 ret = -10000;
10226 Z_scripterrlog("Invalid Array Index passed to mapdata->TileWarpReturnSquare[]: %d\n", indx);
10227
10228 }
10229 else if (mapscr *m = GetMapscr(ri->mapsref))
10230 {
10231 ret = ((m->warpreturnc>>(indx*2))&3) * 10000;
10232 }
10233 else
10234 {
10235 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","str");
10236 ret = -10000;
10237 }
10238 break;
10239 }
10240
10241 case MAPDATASWARPRETSQR:
10242 {
10243 int32_t indx = ri->d[rINDEX] / 10000;
10244 if ( ((unsigned)indx) > 3)
10245 {
10246 ret = -10000;
10247 Z_scripterrlog("Invalid Array Index passed to mapdata->TileWarpReturnSquare[]: %d\n", indx);
10248
10249 }
10250 else if (mapscr *m = GetMapscr(ri->mapsref))
10251 {
10252 ret = ((m->warpreturnc>>(8+(indx*2)))&3) * 10000;
10253 }
10254 else
10255 {
10256 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","str");
10257 ret = -10000;
10258 }
10259 break;
10260 }
10261
10262 case MAPDATAFFWIDTH:
10263 {
10264
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if (mapscr *m = GetMapscr(ri->mapsref))
10265 {
10266 5 int32_t indx = (ri->d[rINDEX] / 10000)-1;
10267
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 if ( indx < 0 || indx > MAXFFCS-1 )
10268 {
10269 Z_scripterrlog("Invalid FFC Index passed to MapData->FFCTileWidth[]: %d\n", indx+1);
10270 ret = -10000;
10271 break;
10272 }
10273 5 ret=(m->ffTileWidth(indx))*10000;
10274 5 }
10275 else
10276 {
10277 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","FFCTileWidth[]");
10278 ret = -10000;
10279 }
10280 5 break;
10281 }
10282
10283 case MAPDATAFFHEIGHT:
10284 {
10285
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if (mapscr *m = GetMapscr(ri->mapsref))
10286 {
10287 5 int32_t indx = (ri->d[rINDEX] / 10000)-1;
10288
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 if ( indx < 0 || indx > MAXFFCS-1 )
10289 {
10290 Z_scripterrlog("Invalid FFC Index passed to MapData->FFCTileHeight[]: %d\n", indx+1);
10291 ret = -10000;
10292 break;
10293 }
10294 5 ret=(m->ffTileHeight(indx))*10000;
10295 5 }
10296 else
10297 {
10298 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","FFCTileHeight[]");
10299 ret = -10000;
10300 }
10301 5 break;
10302
10303 }
10304
10305 case MAPDATAFFEFFECTWIDTH:
10306 {
10307
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if (mapscr *m = GetMapscr(ri->mapsref))
10308 {
10309 5 int32_t indx = (ri->d[rINDEX] / 10000)-1;
10310
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 if ( indx < 0 || indx > MAXFFCS-1 )
10311 {
10312 Z_scripterrlog("Invalid FFC Index passed to MapData->FFCEffectWidth[]: %d\n", indx+1);
10313 ret = -10000;
10314 break;
10315 }
10316 5 ret=(m->ffEffectWidth(indx))*10000;
10317 5 }
10318 else
10319 {
10320 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","FFCEffectWidth[]");
10321 ret = -10000;
10322 }
10323 5 break;
10324 }
10325
10326 case MAPDATAFFEFFECTHEIGHT:
10327 {
10328
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if (mapscr *m = GetMapscr(ri->mapsref))
10329 {
10330 5 int32_t indx = (ri->d[rINDEX] / 10000)-1;
10331
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 if ( indx < 0 || indx > MAXFFCS-1 )
10332 {
10333 Z_scripterrlog("Invalid FFC Index passed to MapData->FFCEffectHeight[]: %d\n", indx+1);
10334 ret = -10000;
10335 break;
10336 }
10337 5 ret=(m->ffEffectHeight(indx))*10000;
10338 5 }
10339 else
10340 {
10341 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","FFCEffectHeight[]");
10342 ret = -10000;
10343 }
10344 5 break;
10345 }
10346
10347
10348 case MAPDATAFFLINK: GET_MAPDATA_FFC_INDEX32(link, "FFCLink", MAXFFCS-1); break; //B, MAXFFCS OF THESE
10349
3/6
✓ Branch 0 taken 32773 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 32773 times.
✓ Branch 4 taken 32773 times.
✗ Branch 5 not taken.
65546 case MAPDATAFFSCRIPT: GET_MAPDATA_FFC_INDEX32(script, "FFCScript", MAXFFCS-1); break; //W, MAXFFCS OF THESE
10350
10351 case MAPDATAINTID: //Same form as SetScreenD()
10352 //SetFFCInitD(ffindex, d, value)
10353 {
10354
1/2
✓ Branch 0 taken 1800 times.
✗ Branch 1 not taken.
1800 if (mapscr *m = GetMapscr(ri->mapsref))
10355 {
10356 1800 int32_t ffid = (ri->d[rINDEX]/10000) -1;
10357 1800 int32_t indx = ri->d[rINDEX2]/10000;
10358
10359
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1800 times.
1800 if ( (unsigned)ffid > MAXFFCS-1 )
10360 {
10361 Z_scripterrlog("Invalid FFC id passed to mapdata->FFCInitD[]: %d",ffid);
10362 ret = -10000;
10363 }
10364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1800 times.
1800 else if ( (unsigned)indx > 7 )
10365 {
10366 Z_scripterrlog("Invalid InitD[] index passed to mapdata->FFCInitD[]: %d",indx);
10367 ret = -10000;
10368 }
10369 else
10370 {
10371 1800 ret = (m->ffcs[ffid].initd[indx]);
10372 }
10373
10374 //int32_t ffindex = ri->d[rINDEX]/10000;
10375 //int32_t d = ri->d[rINDEX2]/10000;
10376 //int32_t v = (value/10000);
10377 1800 }
10378 else
10379 {
10380 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","GetFFCInitD()");
10381 ret = -10000;
10382 }
10383 1800 break;
10384 }
10385
10386
10387
10388 //initd //INT32 , 32 OF THESE, EACH WITH 10 INDICES.
10389
10390 case MAPDATAINITA:
10391 //same form as SetScreenD
10392 {
10393 if (mapscr *m = GetMapscr(ri->mapsref))
10394 {
10395 //int32_t ffindex = ri->d[rINDEX]/10000;
10396 //int32_t d = ri->d[rINDEX2]/10000;
10397 //int32_t v = (value/10000);
10398
10399 int32_t ffid = (ri->d[rINDEX]/10000) -1;
10400 int32_t indx = ri->d[rINDEX2]/10000;
10401
10402 if ( (unsigned)ffid > MAXFFCS-1 )
10403 {
10404 Z_scripterrlog("Invalid FFC id passed to mapdata->FFCInitD[]: %d",ffid);
10405 ret = -10000;
10406 }
10407 else if ( (unsigned)indx > 1 )
10408 {
10409 Z_scripterrlog("Invalid InitD[] index passed to mapdata->FFCInitD[]: %d",indx);
10410 ret = -10000;
10411 }
10412 else
10413 {
10414 ret = (m->ffcs[ffid].inita[indx]);
10415 }
10416 }
10417 else
10418 {
10419 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","GetFFCInitD()");
10420 ret = -10000;
10421 }
10422 break;
10423 }
10424
10425 //inita //INT32, 32 OF THESE, EACH WITH 2
10426
10427 case MAPDATAFFINITIALISED:
10428 {
10429 int32_t indx = ri->d[rINDEX] / 10000;
10430 if (indx < 0 || indx > MAXFFCS-1)
10431 {
10432 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", "FFCRunning", indx);
10433 ret = -10000;
10434 }
10435 else
10436 {
10437 if (mapscr *m = GetMapscr(ri->mapsref))
10438 {
10439 ret = get_script_engine_data(ScriptType::FFC, indx).initialized ? 10000 : 0;
10440 }
10441 else
10442 {
10443 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n", "FFCRunning");
10444 ret = -10000;
10445 }
10446 }
10447 }
10448 break;
10449
10450 case MAPDATASCRIPTENTRY: GET_MAPDATA_VAR_INT32(script_entry, "ScriptEntry"); break; //W
10451 case MAPDATASCRIPTOCCUPANCY: GET_MAPDATA_VAR_INT32(script_occupancy, "ScriptOccupancy"); break;//W
10452 case MAPDATASCRIPTEXIT: GET_MAPDATA_VAR_INT32(script_exit, "ExitScript"); break; //W
10453 case MAPDATAOCEANSFX: GET_MAPDATA_VAR_BYTE(oceansfx, "OceanSFX"); break; //B
10454 case MAPDATABOSSSFX: GET_MAPDATA_VAR_BYTE(bosssfx, "BossSFX"); break; //B
10455 case MAPDATASECRETSFX: GET_MAPDATA_VAR_BYTE(secretsfx, "SecretSFX"); break; //B
10456 case MAPDATAHOLDUPSFX: GET_MAPDATA_VAR_BYTE(holdupsfx, "ItemSFX"); break; //B
10457 case MAPDATASCREENMIDI:
10458 {
10459 if (mapscr *m = GetMapscr(ri->mapsref))
10460 {
10461 ret = ((m->screen_midi+(MIDIOFFSET_MAPSCR-MIDIOFFSET_ZSCRIPT)) *10000);
10462 }
10463 else
10464 {
10465 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","MIDI");
10466 ret = -10000;
10467 }
10468 break;
10469 }
10470 case MAPDATALENSLAYER: GET_MAPDATA_VAR_BYTE(lens_layer, "LensLayer"); break; //B, OLD QUESTS ONLY?
10471 case MAPDATAMAP:
10472 {
10473 if (mapscr *m = GetMapscr(ri->mapsref))
10474 {
10475 ret = getMap(ri->mapsref) * 10000;
10476 }
10477 else
10478 {
10479 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","Map");
10480 ret = -10000;
10481 }
10482 break;
10483 }
10484 case MAPDATASCREEN:
10485 {
10486 if (mapscr *m = GetMapscr(ri->mapsref))
10487 {
10488 ret = getScreen(ri->mapsref) * 10000;
10489 }
10490 else
10491 {
10492 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","Screen");
10493 ret = -10000;
10494 }
10495 break;
10496 }
10497
10498 case MAPDATAFLAGS:
10499 {
10500 if(mapscr *m = GetMapscr(ri->mapsref))
10501 {
10502 if ( get_qr(qr_OLDMAPDATAFLAGS) )
10503 {
10504 ret = get_screenflags(m,vbound(ri->d[rINDEX] / 10000,0,9));
10505 }
10506 else
10507 {
10508 int32_t flagid = (ri->d[rINDEX])/10000;
10509 //bool valtrue = ( value ? 10000 : 0);
10510 switch(flagid)
10511 {
10512 case 0: ret = (m->flags * 10000); break;
10513 case 1: ret = (m->flags2 * 10000); break;
10514 case 2: ret = (m->flags3 * 10000); break;
10515 case 3: ret = (m->flags4 * 10000); break;
10516 case 4: ret = (m->flags5 * 10000); break;
10517 case 5: ret = (m->flags6 * 10000); break;
10518 case 6: ret = (m->flags7 * 10000); break;
10519 case 7: ret = (m->flags8 * 10000); break;
10520 case 8: ret = (m->flags9 * 10000); break;
10521 case 9: ret = (m->flags10 * 10000); break;
10522 default:
10523 {
10524 Z_scripterrlog("Invalid index passed to mapdata->flags[]: %d\n", flagid);
10525 ret = -10000;
10526 break;
10527
10528 }
10529 }
10530 }
10531 }
10532 else
10533 {
10534 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","Flags[]");
10535 ret = -10000;
10536 }
10537
10538 break;
10539 //GET_MAPDATA_BYTE_INDEX //B, 11 OF THESE, flags, flags2-flags10
10540 }
10541
10542 case MAPDATAMISCD:
10543 {
10544 int32_t indx = (ri->d[rINDEX])/10000;
10545 int32_t mi = get_mi(ri->mapsref);
10546 if(unsigned(mi) >= MAX_MI)
10547 {
10548 ret = 0;
10549 break;
10550 }
10551 if( ((unsigned)indx) > 7 )
10552 {
10553 Z_scripterrlog("You were trying to reference an out-of-bounds array index for a screen's D[] array (%ld); valid indices are from 0 to 7.\n", indx);
10554 ret = -10000;
10555 }
10556 else if (mapscr *m = GetMapscr(ri->mapsref))
10557 {
10558 ret = (game->screen_d[mi][indx]) * 10000;
10559 }
10560 else
10561 {
10562 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","D[]");
10563 ret = -10000;
10564 }
10565 break;
10566 }
10567
10568 case MAPDATACOMBODD:
10569 {
10570
1/2
✓ Branch 0 taken 4767898 times.
✗ Branch 1 not taken.
4767898 if (mapscr *m = GetMapscr(ri->mapsref))
10571 {
10572 4767898 int32_t pos = ri->d[rINDEX] / 10000;
10573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4767898 times.
4767898 if(BC::checkComboPos(pos, "mapdata->ComboD[pos]") != SH::_NoError)
10574 {
10575 ret = -10000;
10576 }
10577 else
10578 {
10579 4767898 ret = m->data[pos] * 10000;
10580 }
10581 4767898 }
10582 else
10583 {
10584 Z_scripterrlog("Mapdata->%s pointer (%d) is either invalid or uninitialised.\n","ComboD[]",ri->mapsref);
10585 ret = -10000;
10586 }
10587 4767898 break;
10588 //GET_SCREENDATA_COMBO_VAR(data, "mapdata->ComboD") break;
10589 }
10590
10591 case MAPDATACOMBOCD:
10592 {
10593
1/2
✓ Branch 0 taken 4654485 times.
✗ Branch 1 not taken.
4654485 if (mapscr *m = GetMapscr(ri->mapsref))
10594 {
10595 //int32_t ffindex = ri->d[rINDEX]/10000;
10596 //int32_t d = ri->d[rINDEX2]/10000;
10597 //int32_t v = (value/10000);
10598 4654485 int32_t pos = ri->d[rINDEX] / 10000;
10599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4654485 times.
4654485 if(BC::checkComboPos(pos, "mapdata->ComboC[pos]") != SH::_NoError)
10600 {
10601 ret = -10000;
10602 }
10603 else
10604 {
10605 4654485 ret = m->cset[pos] * 10000;
10606 }
10607 4654485 }
10608 else
10609 {
10610 Z_scripterrlog("Mapdata->%s pointer (%d) is either invalid or uninitialised.\n","ComboC[]",ri->mapsref);
10611 ret = -10000;
10612 }
10613 4654485 break;
10614 }
10615 //GET_SCREENDATA_COMBO_VAR(cset, "mapdata->ComboC") break;
10616
10617 case MAPDATACOMBOFD:
10618 {
10619
1/2
✓ Branch 0 taken 5945377 times.
✗ Branch 1 not taken.
5945377 if (mapscr *m = GetMapscr(ri->mapsref))
10620 {
10621 //int32_t ffindex = ri->d[rINDEX]/10000;
10622 //int32_t d = ri->d[rINDEX2]/10000;
10623 //int32_t v = (value/10000);
10624 5945377 int32_t pos = ri->d[rINDEX] / 10000;
10625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5945377 times.
5945377 if(BC::checkComboPos(pos, "mapdata->ComboF[pos]") != SH::_NoError)
10626 {
10627 ret = -10000;
10628 }
10629 else
10630 {
10631 5945377 ret = m->sflag[pos] * 10000;
10632 }
10633 5945377 }
10634 else
10635 {
10636 Z_scripterrlog("Mapdata->%s pointer (%d) is either invalid or uninitialised.\n","ComboF[]",ri->mapsref);
10637 ret = -10000;
10638 }
10639 5945377 break;
10640 }
10641 //GET_SCREENDATA_COMBO_VAR(sflag, "mapdata->ComboF") break;
10642
10643
10644
10645 case MAPDATACOMBOTD:
10646 {
10647
1/2
✓ Branch 0 taken 2538431 times.
✗ Branch 1 not taken.
2538431 if (mapscr *m = GetMapscr(ri->mapsref))
10648 {
10649 //int32_t ffindex = ri->d[rINDEX]/10000;
10650 //int32_t d = ri->d[rINDEX2]/10000;
10651 //int32_t v = (value/10000);
10652 2538431 int32_t pos = ri->d[rINDEX] / 10000;
10653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2538431 times.
2538431 if(BC::checkComboPos(pos, "mapdata->ComboT[pos]") != SH::_NoError)
10654 {
10655 ret = -10000;
10656
10657 }
10658 else
10659 {
10660 2538431 ret = combobuf[m->data[pos]].type * 10000;
10661 }
10662 2538431 }
10663 else
10664 {
10665 Z_scripterrlog("Mapdata->%s pointer (%d) is either invalid or uninitialised.\n","ComboT[]",ri->mapsref);
10666 ret = -10000;
10667 }
10668 2538431 break;
10669 }
10670 //GET_MAPDATA_COMBO_VAR_BUF(type, "mapdata->ComboT") break;
10671
10672 case MAPDATACOMBOID:
10673 {
10674
1/2
✓ Branch 0 taken 345816 times.
✗ Branch 1 not taken.
345816 if (mapscr *m = GetMapscr(ri->mapsref))
10675 {
10676 //int32_t ffindex = ri->d[rINDEX]/10000;
10677 //int32_t d = ri->d[rINDEX2]/10000;
10678 //int32_t v = (value/10000);
10679 345816 int32_t pos = ri->d[rINDEX] / 10000;
10680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 345816 times.
345816 if(BC::checkComboPos(pos, "mapdata->ComboI[pos]") != SH::_NoError)
10681 {
10682 ret = -10000;
10683 }
10684 else
10685 {
10686 345816 ret = combobuf[m->data[pos]].flag * 10000;
10687 }
10688 345816 }
10689 else
10690 {
10691 Z_scripterrlog("Mapdata->%s pointer (%d) is either invalid or uninitialised.\n","ComboI[]",ri->mapsref);
10692 ret = -10000;
10693 }
10694 345816 break;
10695 //GET_SCREENDATA_COMBO_VAR(data, "mapdata->ComboD") break;
10696 }
10697 //GET_MAPDATA_COMBO_VAR_BUF(flag, "mapdata->ComboI") break;
10698
10699 case MAPDATACOMBOSD:
10700 {
10701
1/2
✓ Branch 0 taken 85947 times.
✗ Branch 1 not taken.
85947 if (mapscr *m = GetMapscr(ri->mapsref))
10702 {
10703 //int32_t ffindex = ri->d[rINDEX]/10000;
10704 //int32_t d = ri->d[rINDEX2]/10000;
10705 //int32_t v = (value/10000);
10706 85947 int32_t pos = ri->d[rINDEX] / 10000;
10707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85947 times.
85947 if(BC::checkComboPos(pos, "mapdata->ComboS[pos]") != SH::_NoError)
10708 {
10709 ret = -10000;
10710 }
10711 else
10712 {
10713 85947 ret = (combobuf[m->data[pos]].walk & 0xF) * 10000;
10714 }
10715 85947 }
10716 else
10717 {
10718 Z_scripterrlog("Mapdata->%s pointer (%d) is either invalid or uninitialised.\n","ComboS[]", ri->mapsref);
10719 ret = -10000;
10720 }
10721 85947 break;
10722 }
10723
10724 case MAPDATACOMBOED:
10725 {
10726 if (mapscr *m = GetMapscr(ri->mapsref))
10727 {
10728 //int32_t ffindex = ri->d[rINDEX]/10000;
10729 //int32_t d = ri->d[rINDEX2]/10000;
10730 //int32_t v = (value/10000);
10731 int32_t pos = ri->d[rINDEX] / 10000;
10732 if(BC::checkComboPos(pos, "mapdata->ComboE[pos]") != SH::_NoError)
10733 {
10734 ret = -10000;
10735 }
10736 else
10737 {
10738 ret = ((combobuf[m->data[pos]].walk & 0xF0)>>4) * 10000;
10739 }
10740 }
10741 else
10742 {
10743 Z_scripterrlog("Mapdata->%s pointer (%d) is either invalid or uninitialised.\n","ComboE[]", ri->mapsref);
10744 ret = -10000;
10745 }
10746 break;
10747 }
10748
10749 case MAPDATASCREENSTATED:
10750 {
10751 if (mapscr *m = GetMapscr(ri->mapsref))
10752 {
10753 int32_t mi = get_mi(ri->mapsref);
10754 if(mi<0) {ret = 0;break;}
10755 ret=((game->maps[mi]>>((ri->d[rINDEX]/10000)))&1)?10000:0;
10756 }
10757 else
10758 {
10759 Z_scripterrlog("Mapdata->%s pointer (%d) is either invalid or uninitialised.\n","State[]", ri->mapsref);
10760 ret = 0;
10761 }
10762 break;
10763 }
10764 case MAPDATAEXSTATED:
10765 {
10766 if (mapscr *m = GetMapscr(ri->mapsref))
10767 {
10768 int32_t mi = get_mi(ri->mapsref);
10769 if(mi<0) {ret = 0;break;}
10770 ret=((game->xstates[mi]>>((ri->d[rINDEX]/10000)))&1)?10000:0;
10771 }
10772 else
10773 {
10774 Z_scripterrlog("Mapdata->%s pointer (%d) is either invalid or uninitialised.\n","State[]", ri->mapsref);
10775 ret = 0;
10776 }
10777 break;
10778 }
10779 case MAPDATALENSSHOWS:
10780 {
10781 ret = 0;
10782 int ind = ri->d[rINDEX]/10000;
10783 if(ind < 0 || ind > 6)
10784 Z_scripterrlog("Bad index mapdata->LensShows[%d]\n",ind);
10785 else if(mapscr *m = GetMapscr(ri->mapsref))
10786 ret = (m->lens_show & (1<<ind)) ? 10000 : 0;
10787 else Z_scripterrlog("mapdata->LensShows[] pointer (%d) is either invalid or uninitialised.\n", ri->mapsref);
10788 break;
10789 }
10790 case MAPDATALENSHIDES:
10791 {
10792 ret = 0;
10793 int ind = ri->d[rINDEX]/10000;
10794 if(ind < 0 || ind > 6)
10795 Z_scripterrlog("Bad index mapdata->LensHides[%d]\n",ind);
10796 else if(mapscr *m = GetMapscr(ri->mapsref))
10797 ret = (m->lens_hide & (1<<ind)) ? 10000 : 0;
10798 else Z_scripterrlog("mapdata->LensHides[] pointer (%d) is either invalid or uninitialised.\n", ri->mapsref);
10799 break;
10800 }
10801 case MAPDATASCREENFLAGSD:
10802 {
10803 if(mapscr *m = GetMapscr(ri->mapsref))
10804 {
10805 ret = get_screenflags(m,vbound(ri->d[rINDEX] / 10000,0,9));
10806 }
10807 else
10808 {
10809 Z_scripterrlog("Mapdata->%s pointer (%d) is either invalid or uninitialised.\n","SFlags[]", ri->mapsref);
10810 ret = -10000;
10811 }
10812 break;
10813 }
10814
10815 case MAPDATASCREENEFLAGSD:
10816 {
10817 if(mapscr *m = GetMapscr(ri->mapsref))
10818 {
10819 ret = get_screeneflags(m,vbound(ri->d[rINDEX] / 10000,0,2));
10820 }
10821 else
10822 {
10823 Z_scripterrlog("Mapdata->%s pointer (%d) is either invalid or uninitialised.\n","EFlags[]", ri->mapsref);
10824 ret = -10000;
10825 }
10826 break;
10827 }
10828
10829 ///----------------------------------------------------------------------------------------------------//
10830 //shopdata sd-> variables
10831
10832 case SHOPDATATYPE:
10833 {
10834 int32_t ref = ri->shopsref;
10835 if ( ref > NUMINFOSHOPS || ref < 0 ) ret = 0;
10836 else ret = ( ( ref <= NUMSHOPS ) ? 10000 : 20000 );
10837 break;
10838 }
10839 case SHOPDATAITEM:
10840 {
10841
10842 int32_t ref = ri->shopsref;
10843 bool isInfo = ( ref > NUMSHOPS && ref <= NUMINFOSHOPS );
10844 int32_t indx = ri->d[rINDEX] / 10000;
10845 if ( indx < 0 || indx > 2 )
10846 {
10847 Z_scripterrlog("Invalid Array Index passed to shopdata->%s: %d\n", indx, "Item");
10848 ret = -10000;
10849 }
10850 else
10851 {
10852 if ( isInfo )
10853 {
10854 Z_scripterrlog("Attempted to load an 'item' from an infoshop, using shop ID: %d\n", ri->shopsref);
10855 ret = -10000;
10856 }
10857 else
10858 {
10859 ret = ((int32_t)(QMisc.shop[ref].item[indx]) * 10000);
10860 }
10861 }
10862 break;
10863 }
10864
10865
10866 // GET_SHOPDATA_VAR_INDEX(item, "Item", 2); break;
10867 case SHOPDATAHASITEM:
10868 {
10869
10870 int32_t ref = ri->shopsref;
10871 bool isInfo = ( ref > NUMSHOPS && ref <= NUMINFOSHOPS );
10872 int32_t indx = ri->d[rINDEX] / 10000;
10873 if ( indx < 0 || indx > 2 )
10874 {
10875 Z_scripterrlog("Invalid Array Index passed to shopdata->%s: %d\n", indx, "HasItem");
10876 ret = -10000;
10877 }
10878 else
10879 {
10880 if ( isInfo )
10881 {
10882 Z_scripterrlog("Attempted to load 'hasitem' from an infoshop, using shop ID: %d\n", ri->shopsref);
10883 ret = -10000;
10884 }
10885 else
10886 {
10887 ret = ((int32_t)(QMisc.shop[ref].hasitem[indx]) * 10000);
10888 }
10889 }
10890 break;
10891 }
10892
10893
10894 //GET_SHOPDATA_VAR_INDEX(hasitem, "HasItem", 2); break;
10895 case SHOPDATAPRICE:
10896 {
10897
10898 int32_t ref = ri->shopsref;
10899 bool isInfo = ( ref > NUMSHOPS && ref <= NUMINFOSHOPS );
10900 int32_t indx = ri->d[rINDEX] / 10000;
10901 if ( indx < 0 || indx > 2 )
10902 {
10903 Z_scripterrlog("Invalid Array Index passed to shopdata->%s: %d\n", indx, "Price");
10904 ret = -10000;
10905 }
10906 else
10907 {
10908 if ( isInfo )
10909 {
10910 ret = ((int32_t)(QMisc.info[ref].price[indx]) * 10000);
10911 }
10912 else
10913 {
10914 ret = ((int32_t)(QMisc.shop[ref].price[indx]) * 10000);
10915 }
10916 }
10917 break;
10918 }
10919
10920
10921 //GET_SHOPDATA_VAR_INDEX(price, "Price", 2); break;
10922 //Pay for info
10923 case SHOPDATASTRING:
10924 {
10925 if (((unsigned)ri->shopsref) > NUMINFOSHOPS)
10926 {
10927 Z_scripterrlog("Invalid shop pointer passed to shopdata->String[]: %d\n", ri->shopsref);
10928 ret = -10000;
10929 }
10930 else
10931 {
10932 int32_t ref = ri->shopsref;
10933 bool isInfo = ( ref > NUMSHOPS && ref <= NUMINFOSHOPS );
10934 int32_t indx = ri->d[rINDEX] / 10000;
10935 if ( indx < 0 || indx > 2 )
10936 {
10937 Z_scripterrlog("Invalid Array Index passed to shopdata->%s: %d\n", indx, "String");
10938 }
10939 else
10940 {
10941 if ( isInfo )
10942 {
10943 ret = ((int32_t)(QMisc.info[ref].str[indx]) * 10000);
10944 }
10945 else
10946 {
10947 ret = ((int32_t)(QMisc.shop[ref].str[indx]) * 10000);
10948 }
10949 }
10950
10951
10952 }
10953
10954 //GET_SHOPDATA_VAR_INDEX(str, String, 2); break;
10955 break;
10956 }
10957
10958
10959 ///----------------------------------------------------------------------------------------------------//
10960 //dmapdata dmd-> variables
10961
10962 //getter
10963 case DMAPDATAID: ret = ri->dmapsref*10000; break; //read-only, equal to CurrentDMap
10964
10965 case DMAPDATAMAP: //byte
10966 {
10967 ret = ((byte)DMaps[ri->dmapsref].map + 1) * 10000; break;
10968 }
10969 case DMAPDATALEVEL: //word
10970 {
10971 ret = ((word)DMaps[ri->dmapsref].level) * 10000; break;
10972 }
10973 case DMAPDATAOFFSET: //char
10974 {
10975 ret = ((char)DMaps[ri->dmapsref].xoff) * 10000; break;
10976 }
10977 case DMAPDATACOMPASS: //byte
10978 {
10979 ret = ((byte)DMaps[ri->dmapsref].compass) * 10000; break;
10980 }
10981 case DMAPDATAPALETTE: //word
10982 {
10983 ret = ((word)DMaps[ri->dmapsref].color) * 10000; break;
10984 }
10985 case DMAPSCRIPT: //word
10986 {
10987 16 ret = (DMaps[ri->dmapsref].script) * 10000; break;
10988 }
10989 case DMAPDATAMIDI: //byte
10990 {
10991 ret = (DMaps[ri->dmapsref].midi-MIDIOFFSET_DMAP) * 10000; break;
10992 }
10993 case DMAPDATACONTINUE: //byte
10994 {
10995 ret = ((byte)DMaps[ri->dmapsref].cont) * 10000; break;
10996 }
10997 case DMAPDATATYPE: //byte
10998 {
10999 ret = ((byte)DMaps[ri->dmapsref].type&dmfTYPE) * 10000; break;
11000 }
11001 case DMAPDATASIDEVIEW: //byte
11002 {
11003 732975 ret = ((DMaps[ri->dmapsref].sideview) ? 10000 : 0); break;
11004 }
11005 case DMAPDATAGRID: //byte[8] --array
11006 {
11007 int32_t indx = ri->d[rINDEX] / 10000;
11008 if ( indx < 0 || indx > 7 )
11009 {
11010 Z_scripterrlog("Invalid index supplied to dmapdata->Grid[]: %d\n", indx);
11011 ret = -10000;
11012 break;
11013 }
11014 else
11015 {
11016 ret = ((byte)DMaps[ri->dmapsref].grid[indx]) * 10000; break;
11017 }
11018 }
11019 case DMAPINITD: //byte[8] --array
11020 {
11021 24 int32_t indx = ri->d[rINDEX] / 10000;
11022
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
24 if ( indx < 0 || indx > 7 )
11023 {
11024 Z_scripterrlog("Invalid index supplied to dmapdata->InitD[]: %d\n", indx);
11025 ret = -10000;
11026 break;
11027 }
11028 else
11029 {
11030 24 ret = DMaps[ri->dmapsref].initD[indx]; break;
11031 }
11032 }
11033 case DMAPDATAMINIMAPTILE: //word - two of these, so let's do MinimapTile[2]
11034 {
11035 int32_t indx = ri->d[rINDEX] / 10000;
11036 switch(indx)
11037 {
11038 case 0: { ret = ((word)DMaps[ri->dmapsref].minimap_1_tile) * 10000; break; }
11039 case 1: { ret = ((word)DMaps[ri->dmapsref].minimap_2_tile) * 10000; break; }
11040 default:
11041 {
11042 Z_scripterrlog("Invalid index supplied to dmapdata->MiniMapTile[]: %d\n", indx);
11043 ret = -10000;
11044 break;
11045 }
11046 }
11047 break;
11048 }
11049 case DMAPDATAMINIMAPCSET: //byte - two of these, so let's do MinimapCSet[2]
11050 {
11051 int32_t indx = ri->d[rINDEX] / 10000;
11052 switch(indx)
11053 {
11054 case 0: { ret = ((byte)DMaps[ri->dmapsref].minimap_1_cset) * 10000; break; }
11055 case 1: { ret = ((byte)DMaps[ri->dmapsref].minimap_2_cset) * 10000; break; }
11056 default:
11057 {
11058 Z_scripterrlog("Invalid index supplied to dmapdata->MiniMapCSet[]: %d\n", indx);
11059 ret = -10000;
11060 break;
11061 }
11062 }
11063 break;
11064 }
11065 case DMAPDATALARGEMAPTILE: //word -- two of these, so let's to LargemapTile[2]
11066 {
11067 int32_t indx = ri->d[rINDEX] / 10000;
11068 switch(indx)
11069 {
11070 case 0: { ret = ((word)DMaps[ri->dmapsref].largemap_1_tile) * 10000; break; }
11071 case 1: { ret = ((word)DMaps[ri->dmapsref].largemap_2_tile) * 10000; break; }
11072 default:
11073 {
11074 Z_scripterrlog("Invalid index supplied to dmapdata->MapTile[]: %d\n", indx);
11075 ret = -10000;
11076 break;
11077 }
11078 }
11079 break;
11080 }
11081 case DMAPDATALARGEMAPCSET: //word -- two of these, so let's to LargemaCSet[2]
11082 {
11083 int32_t indx = ri->d[rINDEX] / 10000;
11084 switch(indx)
11085 {
11086 case 0: { ret = ((byte)DMaps[ri->dmapsref].largemap_1_cset) * 10000; break; }
11087 case 1: { ret = ((byte)DMaps[ri->dmapsref].largemap_2_cset) * 10000; break; }
11088 default:
11089 {
11090 Z_scripterrlog("Invalid index supplied to dmapdata->MapCSet[]: %d\n", indx);
11091 ret = -10000;
11092 break;
11093 }
11094 }
11095 break;
11096 }
11097 case DMAPDATAMUISCTRACK: //byte
11098 {
11099 ret = ((byte)DMaps[ri->dmapsref].tmusictrack) * 10000; break;
11100 }
11101 case DMAPDATASUBSCRA: //byte, active subscreen
11102 {
11103 ret = ((byte)DMaps[ri->dmapsref].active_subscreen) * 10000; break;
11104 }
11105 case DMAPDATASUBSCRP: //byte, passive subscreen
11106 {
11107 ret = ((byte)DMaps[ri->dmapsref].passive_subscreen) * 10000; break;
11108 }
11109 case DMAPDATADISABLEDITEMS: //byte[MAXITEMS]
11110 {
11111 int32_t indx = ri->d[rINDEX] / 10000;
11112 if ( indx < 0 || indx > (MAXITEMS-1) )
11113 {
11114 Z_scripterrlog("Invalid index supplied to dmapdata->Grid[]: %d\n", indx);
11115 ret = -10000;
11116 break;
11117 }
11118 else
11119 {
11120 ret = ((byte)DMaps[ri->dmapsref].disableditems[indx]) * 10000; break;
11121 }
11122 }
11123 case DMAPDATAFLAGARR: //int32_t
11124 {
11125 int32_t indx = ri->d[rINDEX] / 10000;
11126 if ( ((unsigned)indx) > 31 )
11127 {
11128 Z_scripterrlog("Invalid index supplied to dmapdata->Flags[]: %d\n", indx);
11129 ret = -10000;
11130 break;
11131 }
11132 ret = ((DMaps[ri->dmapsref].flags&(1<<indx)) ? 10000:0);
11133 break;
11134 }
11135 case DMAPDATAFLAGS: //int32_t
11136 {
11137 ret = (DMaps[ri->dmapsref].flags) * 10000; break;
11138 }
11139 case DMAPDATAMIRRDMAP:
11140 {
11141 ret = (DMaps[ri->dmapsref].mirrorDMap) * 10000; break;
11142 }
11143 case DMAPDATALOOPSTART:
11144 {
11145 ret = (DMaps[ri->dmapsref].tmusic_loop_start); break;
11146 }
11147 case DMAPDATALOOPEND:
11148 {
11149 ret = (DMaps[ri->dmapsref].tmusic_loop_end); break;
11150 }
11151 case DMAPDATAXFADEIN:
11152 {
11153 ret = (DMaps[ri->dmapsref].tmusic_xfade_in * 10000); break;
11154 }
11155 case DMAPDATAXFADEOUT:
11156 {
11157 ret = (DMaps[ri->dmapsref].tmusic_xfade_out * 10000); break;
11158 }
11159 case MUSICUPDATECOND:
11160 {
11161 ret = ((byte)FFCore.music_update_cond) * 10000; break;
11162 }
11163 case MUSICUPDATEFLAGS:
11164 {
11165 int32_t indx = ri->d[rINDEX] / 10000;
11166 if (indx < 0 || indx > 2)
11167 {
11168 Z_scripterrlog("Invalid Index passed to Audio->MusicRefreshFlags[]: %d\n", indx);
11169 }
11170 ret = ((FFCore.music_update_flags >> indx) & 1) ? 10000 : 0; break;
11171 }
11172 case DMAPDATAASUBSCRIPT: //word
11173 {
11174 22016 ret = (DMaps[ri->dmapsref].active_sub_script) * 10000; break;
11175 }
11176 case DMAPDATAMAPSCRIPT: //byte
11177 {
11178 ret = (DMaps[ri->dmapsref].onmap_script) * 10000; break;
11179 }
11180 case DMAPDATAPSUBSCRIPT: //word
11181 {
11182 ret = (DMaps[ri->dmapsref].passive_sub_script) * 10000; break;
11183 }
11184 case DMAPDATASUBINITD: //byte[8] --array
11185 {
11186 int32_t indx = ri->d[rINDEX] / 10000;
11187 if ( indx < 0 || indx > 7 )
11188 {
11189 Z_scripterrlog("Invalid index supplied to dmapdata->SubInitD[]: %d\n", indx);
11190 ret = -10000;
11191 break;
11192 }
11193 else
11194 {
11195 ret = DMaps[ri->dmapsref].sub_initD[indx]; break;
11196 }
11197 }
11198
11199 case DMAPDATAMAPINITD: //byte[8] --array
11200 {
11201 int32_t indx = ri->d[rINDEX] / 10000;
11202 if ( indx < 0 || indx > 7 )
11203 {
11204 Z_scripterrlog("Invalid index supplied to dmapdata->MapInitD[]: %d\n", indx);
11205 ret = -10000;
11206 break;
11207 }
11208 else
11209 {
11210 ret = DMaps[ri->dmapsref].onmap_initD[indx]; break;
11211 }
11212 }
11213
11214 case DMAPDATACHARTED:
11215 {
11216 int32_t scr = ri->d[rINDEX] / 10000;
11217 ret = -10000;
11218 if(ri->dmapsref >= MAXDMAPS)
11219 {
11220 Z_scripterrlog("Invalid DMap reference used for dmapdata->Charted[]: %d\n", ri->dmapsref);
11221 }
11222 // else if((DMaps[get_currdmap()].type&dmfTYPE) == dmOVERW)
11223 // {
11224 // Z_scripterrlog("dmapdata->Charted[] cannot presently be used on Overworld-type dmaps\n");
11225 // }
11226 else if(((unsigned)(scr)) > 127)
11227 {
11228 Z_scripterrlog("Invalid index supplied to dmapdata->Charted[]: %d\n", scr);
11229 }
11230 else
11231 {
11232 int32_t col = (scr&15)-(DMaps[ri->dmapsref].type==dmOVERW ? 0 : DMaps[ri->dmapsref].xoff);
11233 if((DMaps[ri->dmapsref].type&dmfTYPE)!=dmOVERW ? (((unsigned)col) > 7) : (((unsigned)col) > 15))
11234 break; //Out-of-bounds; don't attempt read!
11235 int32_t di = (ri->dmapsref << 7) + (scr & 0x7F);
11236 ret = 10000 * game->bmaps[di];
11237 }
11238 break;
11239 }
11240 //case DMAPDATAGRAVITY: //unimplemented
11241 //case DMAPDATAJUMPLAYER: //unimplemented
11242
11243 ///----------------------------------------------------------------------------------------------------//
11244 //messagedata msgd-> variables
11245 case MESSAGEDATANEXT: //W
11246 {
11247 int32_t ID = ri->zmsgref;
11248
11249 if(BC::checkMessage(ID, "messagedata->Next") != SH::_NoError)
11250 {
11251 ret = -10000; break;
11252 }
11253 else
11254 {
11255 ret = ((int32_t)MsgStrings[ID].nextstring) * 10000;
11256 break;
11257 }
11258 }
11259
11260 case MESSAGEDATATILE: //W
11261 {
11262 int32_t ID = ri->zmsgref;
11263
11264 if(BC::checkMessage(ID, "messagedata->Tile") != SH::_NoError)
11265 ret = -10000;
11266 else
11267 ret = ((int32_t)MsgStrings[ID].tile) * 10000;
11268 break;
11269 }
11270
11271 case MESSAGEDATACSET: //b
11272 {
11273 int32_t ID = ri->zmsgref;
11274
11275 if(BC::checkMessage(ID, "messagedata->CSet") != SH::_NoError)
11276 ret = -10000;
11277 else
11278 ret = ((int32_t)MsgStrings[ID].cset) * 10000;
11279 break;
11280 }
11281 case MESSAGEDATATRANS: //BOOL
11282 {
11283 int32_t ID = ri->zmsgref;
11284
11285 if(BC::checkMessage(ID, "messagedata->Transparent") != SH::_NoError)
11286 ret = -10000;
11287 else
11288 ret = ((MsgStrings[ID].trans)?10000:0);
11289 break;
11290 }
11291 case MESSAGEDATAFONT: //B
11292 {
11293 int32_t ID = ri->zmsgref;
11294
11295 if(BC::checkMessage(ID, "messagedata->Font") != SH::_NoError)
11296 ret = -10000;
11297 else
11298 ret = (int32_t)MsgStrings[ID].font * 10000;
11299 break;
11300 }
11301 case MESSAGEDATAX: //SHORT
11302 {
11303 int32_t ID = ri->zmsgref;
11304
11305 if(BC::checkMessage(ID, "messagedata->X") != SH::_NoError)
11306 ret = -10000;
11307 else
11308 ret = ((int32_t)MsgStrings[ID].x) * 10000;
11309 break;
11310 }
11311 case MESSAGEDATAY: //SHORT
11312 {
11313 int32_t ID = ri->zmsgref;
11314
11315 if(BC::checkMessage(ID, "messagedata->Y") != SH::_NoError)
11316 ret = -10000;
11317 else
11318 ret = ((int32_t)MsgStrings[ID].y) * 10000;
11319 break;
11320 }
11321 case MESSAGEDATAW: //UNSIGNED SHORT
11322 {
11323 int32_t ID = ri->zmsgref;
11324
11325 if(BC::checkMessage(ID, "messagedata->Width") != SH::_NoError)
11326 ret = -10000;
11327 else
11328 ret = ((int32_t)MsgStrings[ID].w) * 10000;
11329 break;
11330 }
11331 case MESSAGEDATAH: //UNSIGNED SHORT
11332 {
11333 int32_t ID = ri->zmsgref;
11334
11335 if(BC::checkMessage(ID, "messagedata->Height") != SH::_NoError)
11336 ret = -10000;
11337 else
11338 ret = ((int32_t)MsgStrings[ID].h) * 10000;
11339 break;
11340 }
11341 case MESSAGEDATASFX: //BYTE
11342 {
11343 int32_t ID = ri->zmsgref;
11344
11345 if(BC::checkMessage(ID, "messagedata->Sound") != SH::_NoError)
11346 ret = -10000;
11347 else
11348 ret = ((int32_t)MsgStrings[ID].sfx) * 10000;
11349 break;
11350 }
11351 case MESSAGEDATALISTPOS: //WORD
11352 {
11353 int32_t ID = ri->zmsgref;
11354
11355 if(BC::checkMessage(ID, "messagedata->ListPosition") != SH::_NoError)
11356 ret = -10000;
11357 else
11358 ret = ((int32_t)MsgStrings[ID].listpos) * 10000;
11359 break;
11360 }
11361 case MESSAGEDATAVSPACE: //BYTE
11362 {
11363 int32_t ID = ri->zmsgref;
11364
11365 if(BC::checkMessage(ID, "messagedata->VSpace") != SH::_NoError)
11366 ret = -10000;
11367 else
11368 ret = ((int32_t)MsgStrings[ID].vspace) * 10000;
11369 break;
11370 }
11371 case MESSAGEDATAHSPACE: //BYTE
11372 {
11373 int32_t ID = ri->zmsgref;
11374
11375 if(BC::checkMessage(ID, "messagedata->HSpace") != SH::_NoError)
11376 ret = -10000;
11377 else
11378 ret = ((int32_t)MsgStrings[ID].hspace) * 10000;
11379 break;
11380 }
11381 case MESSAGEDATAFLAGS: //BYTE
11382 {
11383 int32_t ID = ri->zmsgref;
11384
11385 if(BC::checkMessage(ID, "messagedata->Flags") != SH::_NoError)
11386 ret = -10000;
11387 else
11388 ret = ((int32_t)MsgStrings[ID].stringflags) * 10000;
11389 break;
11390 }
11391 case MESSAGEDATAMARGINS: //BYTE, 4
11392 {
11393 int32_t indx = ri->d[rINDEX] / 10000;
11394 if ( indx < 0 || indx > 3 )
11395 {
11396 Z_scripterrlog("Invalid index supplied to messagedata->Margins[]: %d\n", indx);
11397 ret = -10000;
11398 break;
11399 }
11400 int32_t ID = ri->zmsgref;
11401
11402 if(BC::checkMessage(ID, "messagedata->Margins[]") != SH::_NoError)
11403 ret = -10000;
11404 else
11405 ret = ((int32_t)MsgStrings[ID].margins[indx]) * 10000;
11406 break;
11407 }
11408 case MESSAGEDATAPORTTILE: //INT
11409 {
11410 int32_t ID = ri->zmsgref;
11411
11412 if(BC::checkMessage(ID, "messagedata->PortraitTile") != SH::_NoError)
11413 ret = -10000;
11414 else
11415 ret = ((int32_t)MsgStrings[ID].portrait_tile) * 10000;
11416 break;
11417 }
11418 case MESSAGEDATAPORTCSET: //BYTE
11419 {
11420 int32_t ID = ri->zmsgref;
11421
11422 if(BC::checkMessage(ID, "messagedata->PortraitCSet") != SH::_NoError)
11423 ret = -10000;
11424 else
11425 ret = ((int32_t)MsgStrings[ID].portrait_cset) * 10000;
11426 break;
11427 }
11428 case MESSAGEDATAPORTX: //BYTE
11429 {
11430 int32_t ID = ri->zmsgref;
11431
11432 if(BC::checkMessage(ID, "messagedata->PortraitX") != SH::_NoError)
11433 ret = -10000;
11434 else
11435 ret = ((int32_t)MsgStrings[ID].portrait_x) * 10000;
11436 break;
11437 }
11438 case MESSAGEDATAPORTY: //BYTE
11439 {
11440 int32_t ID = ri->zmsgref;
11441
11442 if(BC::checkMessage(ID, "messagedata->PortraitY") != SH::_NoError)
11443 ret = -10000;
11444 else
11445 ret = ((int32_t)MsgStrings[ID].portrait_y) * 10000;
11446 break;
11447 }
11448 case MESSAGEDATAPORTWID: //BYTE
11449 {
11450 int32_t ID = ri->zmsgref;
11451
11452 if(BC::checkMessage(ID, "messagedata->PortraitTileWidth") != SH::_NoError)
11453 ret = -10000;
11454 else
11455 ret = ((int32_t)MsgStrings[ID].portrait_tw) * 10000;
11456 break;
11457 }
11458 case MESSAGEDATAPORTHEI: //BYTE
11459 {
11460 int32_t ID = ri->zmsgref;
11461
11462 if(BC::checkMessage(ID, "messagedata->PortraitTileHeight") != SH::_NoError)
11463 ret = -10000;
11464 else
11465 ret = ((int32_t)MsgStrings[ID].portrait_th) * 10000;
11466 break;
11467 }
11468 case MESSAGEDATATEXTLEN: //BYTE
11469 {
11470 int32_t ID = ri->zmsgref;
11471
11472 if(BC::checkMessage(ID, "messagedata->PortraitTileHeight") != SH::_NoError)
11473 ret = -10000;
11474 else
11475 ret = int32_t(MsgStrings[ID].s.size()) * 10000;
11476 break;
11477 }
11478 case MESSAGEDATATEXTWID:
11479 {
11480 ret = do_msgwidth(ri->zmsgref, "messagedata->TextWidth")*10000;
11481 break;
11482 }
11483 case MESSAGEDATATEXTHEI:
11484 {
11485 ret = do_msgheight(ri->zmsgref, "messagedata->TextHeight")*10000;
11486 break;
11487 }
11488 case MESSAGEDATAFLAGSARR: //BOOL, 7
11489 {
11490 int32_t indx = ri->d[rINDEX] / 10000;
11491 int32_t ID = ri->zmsgref;
11492
11493 if(BC::checkMessage(ID, "messagedata->Flags[]") != SH::_NoError)
11494 ret = -10000;
11495 else
11496 {
11497 switch(indx)
11498 {
11499 case 0:
11500 ret = (MsgStrings[ID].stringflags & STRINGFLAG_WRAP)!=0 ? 10000 : 0;
11501 break;
11502 case 1:
11503 ret = (MsgStrings[ID].stringflags & STRINGFLAG_CONT)!=0 ? 10000 : 0;
11504 break;
11505 case 2: //Not implemented
11506 ret = 0;//ret = (MsgStrings[ID].stringflags & STRINGFLAG_CENTER)!=0 ? 10000 : 0;
11507 break;
11508 case 3: //Not implemented
11509 ret = 0;//ret = (MsgStrings[ID].stringflags & STRINGFLAG_RIGHT)!=0 ? 10000 : 0;
11510 break;
11511 case 4:
11512 ret = (MsgStrings[ID].stringflags & STRINGFLAG_FULLTILE)!=0 ? 10000 : 0;
11513 break;
11514 case 5:
11515 ret = (MsgStrings[ID].stringflags & STRINGFLAG_TRANS_BG)!=0 ? 10000 : 0;
11516 break;
11517 case 6:
11518 ret = (MsgStrings[ID].stringflags & STRINGFLAG_TRANS_FG)!=0 ? 10000 : 0;
11519 break;
11520 default:
11521 Z_scripterrlog("Invalid index supplied to messagedata->Flags[]: %d\n", indx);
11522 ret = -10000;
11523 }
11524 }
11525 break;
11526 }
11527
11528 ///----------------------------------------------------------------------------------------------------//
11529 //combodata cd-> Getter variables
11530 #define GET_COMBO_VAR_INT(member, str) \
11531 { \
11532 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
11533 { \
11534 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
11535 ret = -10000; \
11536 } \
11537 else \
11538 { \
11539 ret = (combobuf[ri->combosref].member *10000); \
11540 } \
11541 } \
11542
11543 #define GET_COMBO_VAR_BYTE(member, str) \
11544 { \
11545 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
11546 { \
11547 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
11548 ret = -10000; \
11549 } \
11550 else \
11551 { \
11552 ret = (combobuf[ri->combosref].member *10000); \
11553 } \
11554 } \
11555
11556 #define GET_COMBO_VAR_DWORD(member, str) \
11557 { \
11558 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
11559 { \
11560 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
11561 ret = -10000; \
11562 } \
11563 else \
11564 { \
11565 ret = (combobuf[ri->combosref].member *10000); \
11566 } \
11567 } \
11568
11569 #define GET_COMBO_VAR_INDEX(member, str, indexbound) \
11570 { \
11571 int32_t indx = ri->d[rINDEX] / 10000; \
11572 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
11573 { \
11574 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
11575 ret = -10000; \
11576 } \
11577 else if ( indx < 0 || indx >= indexbound ) \
11578 { \
11579 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, str); \
11580 ret = -10000; \
11581 } \
11582 else \
11583 { \
11584 ret = (combobuf[ri->combosref].member[indx] * 10000); \
11585 } \
11586 }
11587
11588 #define GET_COMBO_BYTE_INDEX(member, str, indexbound) \
11589 { \
11590 int32_t indx = ri->d[rINDEX] / 10000; \
11591 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
11592 { \
11593 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
11594 ret = -10000; \
11595 } \
11596 else if ( indx < 0 || indx >= indexbound ) \
11597 { \
11598 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, str); \
11599 ret = -10000; \
11600 } \
11601 else \
11602 { \
11603 ret = (combobuf[ri->combosref].member[indx] * 100000); \
11604 } \
11605 }
11606
11607 #define GET_COMBO_FLAG(member, str, indexbound) \
11608 { \
11609 int32_t flag = (value/10000); \
11610 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
11611 { \
11612 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
11613 } \
11614 else \
11615 { \
11616 ret = (combobuf[ri->combosref].member&flag) ? 10000 : 0); \
11617 } \
11618 } \
11619
11620 //comboclass macros
11621
11622 #define GET_COMBOCLASS_VAR_INT(member, str) \
11623 { \
11624 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
11625 { \
11626 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
11627 ret = -10000; \
11628 } \
11629 else \
11630 { \
11631 ret = (combo_class_buf[combobuf[ri->combosref].type].member *10000); \
11632 } \
11633 } \
11634
11635 #define GET_COMBOCLASS_VAR_BYTE(member, str) \
11636 { \
11637 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
11638 { \
11639 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
11640 ret = -10000; \
11641 } \
11642 else \
11643 { \
11644 ret = (combo_class_buf[combobuf[ri->combosref].type].member *10000); \
11645 } \
11646 } \
11647
11648 #define GET_COMBOCLASS_VAR_DWORD(member, str) \
11649 { \
11650 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
11651 { \
11652 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
11653 ret = -10000; \
11654 } \
11655 else \
11656 { \
11657 ret = (combo_class_buf[combobuf[ri->combosref].type].member *10000); \
11658 } \
11659 } \
11660
11661 #define GET_COMBOCLASS_VAR_INDEX(member, str, indexbound) \
11662 { \
11663 int32_t indx = ri->d[rINDEX] / 10000; \
11664 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
11665 { \
11666 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
11667 ret = -10000; \
11668 } \
11669 else if ( indx < 0 || indx > indexbound ) \
11670 { \
11671 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, str); \
11672 ret = -10000; \
11673 } \
11674 else \
11675 { \
11676 ret = (combo_class_buf[combobuf[ri->combosref].type].member[indx] * 10000); \
11677 } \
11678 }
11679
11680 #define GET_COMBOCLASS_BYTE_INDEX(member, str, indexbound) \
11681 { \
11682 int32_t indx = ri->d[rINDEX] / 10000; \
11683 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
11684 { \
11685 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
11686 ret = -10000; \
11687 } \
11688 else if ( indx < 0 || indx > indexbound ) \
11689 { \
11690 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, str); \
11691 ret = -10000; \
11692 } \
11693 else \
11694 { \
11695 ret = (combo_class_buf[combobuf[ri->combosref].type].member[indx] * 100000); \
11696 } \
11697 }
11698
11699 #define GET_COMBOCLASS_FLAG(member, str, indexbound) \
11700 { \
11701 int32_t flag = (value/10000); \
11702 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
11703 { \
11704 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
11705 } \
11706 else \
11707 { \
11708 ret = (combo_class_buf[combobuf[ri->combosref].type].member&flag) ? 10000 : 0); \
11709 } \
11710 } \
11711
11712 case COMBOXR:
11713 {
11714 //ri->combosref = id; //'this' pointer
11715 //ri->comboposref = i; //used for X(), Y(), Layer(), and so forth.
11716
1/2
✓ Branch 0 taken 11261 times.
✗ Branch 1 not taken.
11261 if ( curScriptType == ScriptType::Combo )
11717 {
11718 11261 int pos = combopos_ref_to_pos(ri->comboposref);
11719 11261 ret = (( COMBOX(pos) ) * 10000); //comboscriptstack[i]
11720 //this may be wrong...may need a special new var for this, storing the exact combopos
11721 //i is the current script number
11722 11261 }
11723 else
11724 {
11725 Z_scripterrlog("combodata->X() can only be called by combodata scripts, but you tried to use it from script type %s, script token %s\n", ScriptTypeToString(curScriptType), comboscriptmap[ri->combosref].scriptname.c_str() );
11726 ret = -10000;
11727 }
11728 11261 break;
11729 }
11730
11731 case COMBOYR:
11732 {
11733
1/2
✓ Branch 0 taken 11261 times.
✗ Branch 1 not taken.
11261 if ( curScriptType == ScriptType::Combo )
11734 {
11735 11261 int pos = combopos_ref_to_pos(ri->comboposref);
11736 11261 ret = (( COMBOY(pos) ) * 10000); //comboscriptstack[i]
11737 11261 }
11738 else
11739 {
11740 Z_scripterrlog("combodata->Y() can only be called by combodata scripts, but you tried to use it from script type %s, script token %s\n", ScriptTypeToString(curScriptType), comboscriptmap[ri->combosref].scriptname.c_str() );
11741 ret = -10000;
11742 }
11743 11261 break;
11744 }
11745 case COMBOPOSR:
11746 {
11747
1/2
✓ Branch 0 taken 33759 times.
✗ Branch 1 not taken.
33759 if ( curScriptType == ScriptType::Combo )
11748 {
11749 33759 int pos = combopos_ref_to_pos(ri->comboposref);
11750 33759 ret = pos * 10000; //comboscriptstack[i]
11751 33759 }
11752 else
11753 {
11754 Z_scripterrlog("combodata->Pos() can only be called by combodata scripts, but you tried to use it from script type %s, script token %s\n", ScriptTypeToString(curScriptType), comboscriptmap[ri->combosref].scriptname.c_str() );
11755 ret = -10000;
11756 }
11757 33759 break;
11758 }
11759 case COMBOLAYERR:
11760 {
11761
1/2
✓ Branch 0 taken 11044 times.
✗ Branch 1 not taken.
11044 if ( curScriptType == ScriptType::Combo )
11762 {
11763 11044 ret = (( ((ri->comboposref)/176) ) * 10000); //comboscriptstack[i]
11764 11044 }
11765 else
11766 {
11767 Z_scripterrlog("combodata->Pos() can only be called by combodata scripts, but you tried to use it from script type %s, script token %s\n", ScriptTypeToString(curScriptType), comboscriptmap[ri->combosref].scriptname.c_str() );
11768 ret = -10000;
11769 }
11770 11044 break;
11771 }
11772
11773 //NEWCOMBO STRUCT
11774
2/4
✓ Branch 0 taken 4546 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4546 times.
4546 case COMBODTILE: GET_COMBO_VAR_DWORD(tile, "Tile"); break; //word
11775 case COMBODOTILE: GET_COMBO_VAR_DWORD(o_tile, "OriginalTile"); break; //word
11776 case COMBODFRAME: GET_COMBO_VAR_BYTE(cur_frame, "Frame"); break; //char
11777 case COMBODACLK: GET_COMBO_VAR_BYTE(aclk, "AClk"); break; //char
11778 case COMBODASPEED: GET_COMBO_VAR_BYTE(speed, "ASpeed"); break; //char
11779
2/4
✓ Branch 0 taken 4546 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4546 times.
4546 case COMBODFLIP: GET_COMBO_VAR_BYTE(flip, "Flip"); break; //char
11780 case COMBODWALK:
11781 {
11782 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
11783 {
11784 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "Walk");
11785 ret = -10000;
11786 }
11787 else
11788 {
11789 ret = ((combobuf[ri->combosref].walk&0x0F) *10000);
11790 }
11791 break;
11792 }
11793 case COMBODEFFECT:
11794 {
11795 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
11796 {
11797 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "Effect");
11798 ret = -10000;
11799 }
11800 else
11801 {
11802 ret = (((combobuf[ri->combosref].walk&0xF0)>>4) *10000);
11803 }
11804 break;
11805 }
11806
2/4
✓ Branch 0 taken 4890 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4890 times.
4890 case COMBODTYPE: GET_COMBO_VAR_BYTE(type, "Type"); break; //char
11807 case COMBODCSET:
11808 {
11809 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
11810 {
11811 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "CSet2");
11812 ret = -10000;
11813 }
11814 else
11815 {
11816 bool neg = combobuf[ri->combosref].csets&0x8;
11817 ret = ((combobuf[ri->combosref].csets&0x7) * (neg ? -10000 : 10000));
11818 }
11819 break;
11820 }
11821 case COMBODCSET2FLAGS:
11822 {
11823 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
11824 {
11825 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "CSet2Flags");
11826 }
11827 else
11828 {
11829 ret = ((combobuf[ri->combosref].csets & 0xF0) >> 4) * 10000;
11830 }
11831 break;
11832 }
11833 case COMBODFOO: break; //W
11834
2/4
✓ Branch 0 taken 22172 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 22172 times.
22172 case COMBODATASCRIPT: GET_COMBO_VAR_DWORD(script, "Script"); break; //W
11835 case COMBODFRAMES: GET_COMBO_VAR_BYTE(frames, "Frames"); break; //C
11836 case COMBODNEXTD: GET_COMBO_VAR_DWORD(speed, "NextData"); break; //W
11837 case COMBODNEXTC: GET_COMBO_VAR_BYTE(nextcombo, "NextCSet"); break; //C
11838 case COMBODFLAG: GET_COMBO_VAR_BYTE(nextcset, "Flag"); break; //C
11839 case COMBODSKIPANIM: GET_COMBO_VAR_BYTE(skipanim, "SkipAnim"); break; //C
11840 case COMBODNEXTTIMER: GET_COMBO_VAR_DWORD(nexttimer, "NextTimer"); break; //W
11841 case COMBODAKIMANIMY: GET_COMBO_VAR_BYTE(skipanimy, "SkipAnimY"); break; //C
11842 case COMBODANIMFLAGS: GET_COMBO_VAR_BYTE(animflags, "AnimFlags"); break; //C
11843 case COMBODEXPANSION: GET_COMBO_BYTE_INDEX(expansion, "Expansion[]", 6); break; //C , 6 INDICES
11844 case COMBODATTRIBUTES:
11845 {
11846 66 int32_t indx = ri->d[rINDEX] / 10000;
11847
2/4
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 66 times.
66 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
11848 {
11849 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "Attributes[]");
11850 ret = -10000;
11851 }
11852
2/4
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 66 times.
66 else if ( indx < 0 || indx > 4 )
11853 {
11854 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, "Attributes[]");
11855 ret = -10000;
11856 }
11857 else
11858 {
11859 66 ret = (combobuf[ri->combosref].attributes[indx]);
11860 }
11861 }
11862 66 break;
11863 //case COMBODATAINITD: GET_COMBO_VAR_INDEX(initd, "InitD[]", 2); break; //LONG, 4 INDICES, INDIVIDUAL VALUES
11864 case COMBODATAINITD:
11865 {
11866 1636 int32_t indx = ri->d[rINDEX] / 10000;
11867
2/4
✓ Branch 0 taken 1636 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1636 times.
1636 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
11868 {
11869 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "InitD[]");
11870 ret = -10000;
11871 }
11872
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1636 times.
1636 else if ( ((unsigned)indx) > 2 )
11873 {
11874 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, "InitD[]");
11875 ret = -10000;
11876 }
11877 else
11878 {
11879 1636 ret = (combobuf[ri->combosref].initd[indx] * (get_qr(qr_COMBODATA_INITD_MULT_TENK) ? 10000 : 1));
11880 }
11881 1636 break;
11882 }
11883
4/8
✓ Branch 0 taken 568 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 568 times.
✓ Branch 4 taken 568 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 568 times.
1136 case COMBODATTRIBYTES: GET_COMBO_VAR_INDEX(attribytes, "Attribytes[]", 8); break; //LONG, 4 INDICES, INDIVIDUAL VALUES
11884
4/8
✓ Branch 0 taken 136 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 136 times.
✓ Branch 4 taken 136 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 136 times.
272 case COMBODATTRISHORTS: GET_COMBO_VAR_INDEX(attrishorts, "Attrishorts[]", 8); break; //LONG, 4 INDICES, INDIVIDUAL VALUES
11885 case COMBODUSRFLAGARR:
11886 {
11887 int32_t indx = ri->d[rINDEX] / 10000;
11888 if (ri->combosref < 0 || ri->combosref >(MAXCOMBOS - 1))
11889 {
11890 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", "Flags[]", (ri->combosref * 10000));
11891 ret = 0;
11892 }
11893 else if (((unsigned)indx) > 15)
11894 {
11895 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", "Flags[]", indx);
11896 ret = 0;
11897 }
11898 else
11899 {
11900 ret = (combobuf[ri->combosref].usrflags & 1 << indx) ? 10000L : 0L;
11901 }
11902 break;
11903 }
11904 case COMBODGENFLAGARR:
11905 {
11906 int32_t indx = ri->d[rINDEX] / 10000;
11907 if (ri->combosref < 0 || ri->combosref >(MAXCOMBOS - 1))
11908 {
11909 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", "GenFlags[]", (ri->combosref * 10000));
11910 ret = 0;
11911 }
11912 else if (((unsigned)indx) > 1)
11913 {
11914 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", "GenFlags[]", indx);
11915 ret = 0;
11916 }
11917 else
11918 {
11919 ret = (combobuf[ri->combosref].genflags & (1 << indx)) ? 10000L : 0L;
11920 }
11921 break;
11922 }
11923 case COMBODUSRFLAGS: GET_COMBO_VAR_INT(usrflags, "UserFlags"); break; //LONG
11924 case COMBODTRIGGERFLAGS: GET_COMBO_VAR_INDEX(triggerflags, "TriggerFlags[]", 6); break; //LONG 3 INDICES AS FLAGSETS
11925 case COMBODTRIGGERFLAGS2:
11926 {
11927 int32_t indx = ri->d[rINDEX] / 10000;
11928 ret = -10000;
11929 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
11930 {
11931 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TrigFlags[]");
11932 }
11933 else if ( unsigned(indx) >= 32*6 )
11934 {
11935 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, "TrigFlags[]");
11936 }
11937 else
11938 {
11939 ret = (combobuf[ri->combosref].triggerflags[indx/32] & (1<<indx%32)) ? 10000L : 0L;
11940 }
11941 break;
11942 }
11943 case COMBODTRIGGERBUTTON:
11944 {
11945 int32_t indx = ri->d[rINDEX] / 10000;
11946 ret = -10000;
11947 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
11948 {
11949 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerButton[]");
11950 }
11951 else if ( unsigned(indx) >= 8 )
11952 {
11953 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, "TriggerButton[]");
11954 }
11955 else
11956 {
11957 ret = (combobuf[ri->combosref].triggerbtn & (1<<indx)) ? 10000L : 0L;
11958 }
11959 break;
11960 }
11961 case COMBODTRIGGERITEM:
11962 {
11963 ret = -10000;
11964 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
11965 {
11966 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerItem");
11967 }
11968 else ret = (combobuf[ri->combosref].triggeritem) * 10000;
11969 break;
11970 }
11971 case COMBODTRIGGERTIMER:
11972 {
11973 ret = -10000;
11974 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
11975 {
11976 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerTimer");
11977 }
11978 else ret = (combobuf[ri->combosref].trigtimer) * 10000;
11979 break;
11980 }
11981 case COMBODTRIGGERSFX:
11982 {
11983 ret = -10000;
11984 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
11985 {
11986 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerSFX");
11987 }
11988 else ret = (combobuf[ri->combosref].trigsfx) * 10000;
11989 break;
11990 }
11991 case COMBODTRIGGERCHANGECMB:
11992 {
11993 ret = -10000;
11994 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
11995 {
11996 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerChange");
11997 }
11998 else ret = (combobuf[ri->combosref].trigchange) * 10000;
11999 break;
12000 }
12001 case COMBODTRIGGERPROX:
12002 {
12003 ret = -10000;
12004 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12005 {
12006 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerProximity");
12007 }
12008 else ret = (combobuf[ri->combosref].trigprox) * 10000;
12009 break;
12010 }
12011 case COMBODTRIGGERLIGHTBEAM:
12012 {
12013 ret = -10000;
12014 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12015 {
12016 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerLightBeam");
12017 }
12018 else ret = (combobuf[ri->combosref].triglbeam) * 10000;
12019 break;
12020 }
12021 case COMBODTRIGGERCTR:
12022 {
12023 ret = -10000;
12024 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12025 {
12026 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerCounter");
12027 }
12028 else ret = (combobuf[ri->combosref].trigctr) * 10000;
12029 break;
12030 }
12031 case COMBODTRIGGERCTRAMNT:
12032 {
12033 ret = -10000;
12034 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12035 {
12036 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerCtrAmount");
12037 }
12038 else ret = (combobuf[ri->combosref].trigctramnt) * 10000;
12039 break;
12040 }
12041 case COMBODTRIGGERCOOLDOWN:
12042 {
12043 ret = -10000;
12044 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12045 {
12046 Z_scripterrlog("Invalid Combo ID passed to combodata->TriggerCooldown: %d\n", (ri->combosref*10000));
12047 }
12048 else ret = (combobuf[ri->combosref].trigcooldown) * 10000;
12049 break;
12050 }
12051 case COMBODTRIGGERCOPYCAT:
12052 {
12053 ret = -10000;
12054 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12055 {
12056 Z_scripterrlog("Invalid Combo ID passed to combodata->TriggerCopycat: %d\n", (ri->combosref*10000));
12057 }
12058 else ret = (combobuf[ri->combosref].trigcopycat) * 10000;
12059 break;
12060 }
12061 case COMBODTRIGITEMPICKUP:
12062 {
12063 ret = -10000;
12064 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12065 {
12066 Z_scripterrlog("Invalid Combo ID passed to combodata->TriggerSpawnItemPickup: %d\n", (ri->combosref*10000));
12067 }
12068 else ret = (combobuf[ri->combosref].spawnip) * 10000;
12069 break;
12070 }
12071 case COMBODTRIGEXSTATE:
12072 {
12073 ret = -10000;
12074 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12075 {
12076 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigExState: %d\n", (ri->combosref*10000));
12077 }
12078 else ret = (combobuf[ri->combosref].exstate) * 10000;
12079 break;
12080 }
12081 case COMBODTRIGSPAWNENEMY:
12082 {
12083 ret = -10000;
12084 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12085 {
12086 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigSpawnEnemy: %d\n", (ri->combosref*10000));
12087 }
12088 else ret = (combobuf[ri->combosref].spawnenemy) * 10000;
12089 break;
12090 }
12091 case COMBODTRIGSPAWNITEM:
12092 {
12093 ret = -10000;
12094 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12095 {
12096 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigSpawnItem: %d\n", (ri->combosref*10000));
12097 }
12098 else ret = (combobuf[ri->combosref].spawnitem) * 10000;
12099 break;
12100 }
12101 case COMBODTRIGCSETCHANGE:
12102 {
12103 ret = -10000;
12104 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12105 {
12106 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigCSetChange: %d\n", (ri->combosref*10000));
12107 }
12108 else ret = (combobuf[ri->combosref].trigcschange) * 10000;
12109 break;
12110 }
12111 case COMBODLIFTGFXCOMBO:
12112 {
12113 ret = -10000;
12114 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12115 {
12116 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftGFXCombo: %d\n", (ri->combosref*10000));
12117 }
12118 else ret = (combobuf[ri->combosref].liftcmb) * 10000;
12119 break;
12120 }
12121 case COMBODLIFTGFXCCSET:
12122 {
12123 ret = -10000;
12124 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12125 {
12126 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftGFXCSet: %d\n", (ri->combosref*10000));
12127 }
12128 else ret = (combobuf[ri->combosref].liftcs) * 10000;
12129 break;
12130 }
12131 case COMBODLIFTUNDERCMB:
12132 {
12133 ret = -10000;
12134 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12135 {
12136 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftUnderCombo: %d\n", (ri->combosref*10000));
12137 }
12138 else ret = (combobuf[ri->combosref].liftundercmb) * 10000;
12139 break;
12140 }
12141 case COMBODLIFTUNDERCS:
12142 {
12143 ret = -10000;
12144 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12145 {
12146 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftUnderCSet: %d\n", (ri->combosref*10000));
12147 }
12148 else ret = (combobuf[ri->combosref].liftundercs) * 10000;
12149 break;
12150 }
12151 case COMBODLIFTDAMAGE:
12152 {
12153 ret = -10000;
12154 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12155 {
12156 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftDamage: %d\n", (ri->combosref*10000));
12157 }
12158 else ret = (combobuf[ri->combosref].liftdmg) * 10000;
12159 break;
12160 }
12161 case COMBODLIFTLEVEL:
12162 {
12163 ret = -10000;
12164 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12165 {
12166 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftLevel: %d\n", (ri->combosref*10000));
12167 }
12168 else ret = (combobuf[ri->combosref].liftlvl) * 10000;
12169 break;
12170 }
12171 case COMBODLIFTITEM:
12172 {
12173 ret = -10000;
12174 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12175 {
12176 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftItem: %d\n", (ri->combosref*10000));
12177 }
12178 else ret = (combobuf[ri->combosref].liftitm) * 10000;
12179 break;
12180 }
12181 case COMBODLIFTFLAGS:
12182 {
12183 ret = -10000;
12184 int32_t indx = ri->d[rINDEX] / 10000;
12185 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12186 {
12187 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftFlags[]: %d\n", (ri->combosref*10000));
12188 break;
12189 }
12190 if ( unsigned(indx) > 7 )
12191 {
12192 Z_scripterrlog("Invalid index supplied to combodata->LiftFlags[]: %d\n", indx);
12193 break;
12194 }
12195 ret = (combobuf[ri->combosref].liftflags & (1<<indx)) ? 10000 : 0;
12196 break;
12197 }
12198 case COMBODLIFTGFXTYPE:
12199 {
12200 ret = -10000;
12201 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12202 {
12203 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftGFXType: %d\n", (ri->combosref*10000));
12204 }
12205 else ret = (combobuf[ri->combosref].liftgfx) * 10000;
12206 break;
12207 }
12208 case COMBODLIFTGFXSPRITE:
12209 {
12210 ret = -10000;
12211 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12212 {
12213 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftGFXSprite: %d\n", (ri->combosref*10000));
12214 }
12215 else ret = (combobuf[ri->combosref].liftsprite) * 10000;
12216 break;
12217 }
12218 case COMBODLIFTSFX:
12219 {
12220 ret = -10000;
12221 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12222 {
12223 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftSFX: %d\n", (ri->combosref*10000));
12224 }
12225 else ret = (combobuf[ri->combosref].liftsfx) * 10000;
12226 break;
12227 }
12228 case COMBODLIFTBREAKSPRITE:
12229 {
12230 ret = -10000;
12231 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12232 {
12233 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftBreakSprite: %d\n", (ri->combosref*10000));
12234 }
12235 else ret = (combobuf[ri->combosref].liftbreaksprite) * 10000;
12236 break;
12237 }
12238 case COMBODLIFTBREAKSFX:
12239 {
12240 ret = -10000;
12241 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12242 {
12243 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftBreakSFX: %d\n", (ri->combosref*10000));
12244 }
12245 else ret = (combobuf[ri->combosref].liftbreaksfx) * 10000;
12246 break;
12247 }
12248 case COMBODLIFTHEIGHT:
12249 {
12250 ret = -10000;
12251 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12252 {
12253 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftHeight: %d\n", (ri->combosref*10000));
12254 }
12255 else ret = (combobuf[ri->combosref].lifthei) * 10000;
12256 break;
12257 }
12258 case COMBODLIFTTIME:
12259 {
12260 ret = -10000;
12261 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12262 {
12263 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftTime: %d\n", (ri->combosref*10000));
12264 }
12265 else ret = (combobuf[ri->combosref].lifttime) * 10000;
12266 break;
12267 }
12268 case COMBODLIFTWEAPONITEM:
12269 {
12270 ret = -10000;
12271 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12272 {
12273 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftWeaponItem: %d\n", (ri->combosref*10000));
12274 }
12275 else ret = (combobuf[ri->combosref].lift_parent_item) * 10000;
12276 break;
12277 }
12278 case COMBODTRIGGERLSTATE:
12279 {
12280 ret = -10000;
12281 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12282 {
12283 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigLevelState: %d\n", (ri->combosref*10000));
12284 }
12285 else ret = (combobuf[ri->combosref].trig_lstate) * 10000;
12286 break;
12287 }
12288 case COMBODTRIGGERGSTATE:
12289 {
12290 ret = -10000;
12291 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12292 {
12293 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigGlobalState: %d\n", (ri->combosref*10000));
12294 }
12295 else ret = (combobuf[ri->combosref].trig_gstate) * 10000;
12296 break;
12297 }
12298 case COMBODTRIGGERGROUP:
12299 {
12300 ret = -10000;
12301 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12302 {
12303 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigGroup: %d\n", (ri->combosref*10000));
12304 }
12305 else ret = (combobuf[ri->combosref].trig_group) * 10000;
12306 break;
12307 }
12308 case COMBODTRIGGERGROUPVAL:
12309 {
12310 ret = -10000;
12311 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12312 {
12313 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigGroupVal: %d\n", (ri->combosref*10000));
12314 }
12315 else ret = (combobuf[ri->combosref].trig_group_val) * 10000;
12316 break;
12317 }
12318 case COMBODTRIGGERGTIMER:
12319 {
12320 ret = -10000;
12321 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12322 {
12323 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigGStateTimer: %d\n", (ri->combosref*10000));
12324 }
12325 else ret = (combobuf[ri->combosref].trig_statetime) * 10000;
12326 break;
12327 }
12328 case COMBODTRIGGERGENSCRIPT:
12329 {
12330 ret = -10000;
12331 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
12332 {
12333 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigGenScript: %d\n", (ri->combosref*10000));
12334 }
12335 else ret = (combobuf[ri->combosref].trig_genscr) * 10000;
12336 break;
12337 }
12338
12339 case COMBODTRIGGERLEVEL: GET_COMBO_VAR_INT(triggerlevel, "TriggerLevel"); break; //LONG
12340 10673 case COMBODATAID: ret = (ri->combosref*10000); break;
12341 //COMBOCLASS STRUCT
12342 //case COMBODNAME: //CHAR[64], STRING
12343 case COMBODBLOCKNPC: GET_COMBOCLASS_VAR_BYTE(block_enemies, "BlockNPC"); break; //C
12344 case COMBODBLOCKHOLE: GET_COMBOCLASS_VAR_BYTE(block_hole, "BlockHole"); break; //C
12345 case COMBODBLOCKTRIG: GET_COMBOCLASS_VAR_BYTE(block_trigger, "BlockTrigger"); break; //C
12346 case COMBODBLOCKWEAPON: GET_COMBOCLASS_BYTE_INDEX(block_weapon, "BlockWeapon[]", 32); break; //C, 32 INDICES
12347 case COMBODCONVXSPEED: GET_COMBOCLASS_VAR_DWORD(conveyor_x_speed, "ConveyorSpeedX"); break; //SHORT
12348 case COMBODCONVYSPEED: GET_COMBOCLASS_VAR_DWORD(conveyor_y_speed, "ConveyorSpeedY"); break; //SHORT
12349 case COMBODSPAWNNPC: GET_COMBOCLASS_VAR_DWORD(create_enemy, "SpawnNPC"); break; //W
12350 case COMBODSPAWNNPCWHEN: GET_COMBOCLASS_VAR_BYTE(create_enemy_when, "SpawnNPCWhen"); break; //C
12351 case COMBODSPAWNNPCCHANGE: GET_COMBOCLASS_VAR_INT(create_enemy_change, "SpawnNPCChange"); break; //LONG
12352 case COMBODDIRCHANGETYPE: GET_COMBOCLASS_VAR_BYTE(directional_change_type, "DirChange"); break; //C
12353 case COMBODDISTANCECHANGETILES: GET_COMBOCLASS_VAR_INT(distance_change_tiles, "DistanceChangeTiles"); break; //LONG
12354 case COMBODDIVEITEM: GET_COMBOCLASS_VAR_DWORD(dive_item, "DiveItem"); break; //SHORT
12355 case COMBODDOCK: GET_COMBOCLASS_VAR_BYTE(dock, "Dock"); break; //C
12356 case COMBODFAIRY: GET_COMBOCLASS_VAR_BYTE(fairy, "Fairy"); break; //C
12357 case COMBODFFATTRCHANGE: GET_COMBOCLASS_VAR_BYTE(ff_combo_attr_change, "FFCAttributeChange"); break; //C
12358 case COMBODFOORDECOTILE: GET_COMBOCLASS_VAR_INT(foot_decorations_tile, "DecorationTile"); break; //LONG
12359 case COMBODFOORDECOTYPE: GET_COMBOCLASS_VAR_BYTE(foot_decorations_type, "DecorationType"); break; //C
12360 case COMBODHOOKSHOTPOINT: GET_COMBOCLASS_VAR_BYTE(hookshot_grab_point, "Hookshot"); break; //C
12361 case COMBODLADDERPASS: GET_COMBOCLASS_VAR_BYTE(ladder_pass, "Ladder"); break; //C
12362 case COMBODLOCKBLOCK: GET_COMBOCLASS_VAR_BYTE(lock_block_type, "LockBlock"); break; //C
12363 case COMBODLOCKBLOCKCHANGE: GET_COMBOCLASS_VAR_INT(lock_block_change, "LockBlockChange"); break; //LONG
12364 case COMBODMAGICMIRROR: GET_COMBOCLASS_VAR_BYTE(magic_mirror_type, "Mirror"); break; //C
12365 case COMBODMODHPAMOUNT: GET_COMBOCLASS_VAR_DWORD(modify_hp_amount, "DamageAmount"); break; //SHORT
12366 case COMBODMODHPDELAY: GET_COMBOCLASS_VAR_BYTE(modify_hp_delay, "DamageDelay"); break; //C
12367 case COMBODMODHPTYPE: GET_COMBOCLASS_VAR_BYTE(modify_hp_type, "DamageType"); break; //C
12368 case COMBODNMODMPAMOUNT: GET_COMBOCLASS_VAR_DWORD(modify_mp_amount, "MagicAmount"); break; //SHORT
12369 case COMBODMODMPDELAY: GET_COMBOCLASS_VAR_BYTE(modify_mp_delay, "MagicDelay"); break; //C
12370 case COMBODMODMPTYPE: GET_COMBOCLASS_VAR_BYTE(modify_mp_type, "MagicType"); break; //C
12371 case COMBODNOPUSHBLOCK: GET_COMBOCLASS_VAR_BYTE(no_push_blocks, "NoPushBlocks"); break; //C
12372 case COMBODOVERHEAD: GET_COMBOCLASS_VAR_BYTE(overhead, "Overhead"); break; //C
12373 case COMBODPLACENPC: GET_COMBOCLASS_VAR_BYTE(place_enemy, "PlaceNPC"); break; //C
12374 case COMBODPUSHDIR: GET_COMBOCLASS_VAR_BYTE(push_direction, "PushDir"); break; //C
12375 case COMBODPUSHWAIT: GET_COMBOCLASS_VAR_BYTE(push_wait, "PushDelay"); break; //C
12376 case COMBODPUSHHEAVY: GET_COMBOCLASS_VAR_BYTE(push_weight, "PushHeavy"); break; //C
12377 case COMBODPUSHED: GET_COMBOCLASS_VAR_BYTE(pushed, "Pushed"); break; //C
12378 case COMBODRAFT: GET_COMBOCLASS_VAR_BYTE(raft, "Raft"); break; //C
12379 case COMBODRESETROOM: GET_COMBOCLASS_VAR_BYTE(reset_room, "ResetRoom"); break; //C
12380 case COMBODSAVEPOINTTYPE: GET_COMBOCLASS_VAR_BYTE(save_point_type, "SavePoint"); break; //C
12381 case COMBODSCREENFREEZETYPE: GET_COMBOCLASS_VAR_BYTE(screen_freeze_type, "FreezeScreen"); break; //C
12382 case COMBODSECRETCOMBO: GET_COMBOCLASS_VAR_BYTE(secret_combo, "SecretCombo"); break; //C
12383 case COMBODSINGULAR: GET_COMBOCLASS_VAR_BYTE(singular, "Singular"); break; //C
12384 case COMBODSLOWWALK: GET_COMBOCLASS_VAR_BYTE(slow_movement, "SlowWalk"); break; //C
12385 case COMBODSTATUETYPE: GET_COMBOCLASS_VAR_BYTE(statue_type, "Statue"); break; //C
12386 case COMBODSTEPTYPE: GET_COMBOCLASS_VAR_BYTE(step_type, "Step"); break; //C
12387 case COMBODSTEPCHANGEINTO: GET_COMBOCLASS_VAR_INT(step_change_to, "StepChange"); break; //LONG
12388 case COMBODSTRIKEWEAPONS: GET_COMBOCLASS_BYTE_INDEX(strike_weapons, "Strike[]", 32); break; //BYTE, 32 INDICES.
12389 case COMBODSTRIKEREMNANTS: GET_COMBOCLASS_VAR_INT(strike_remnants, "StrikeRemnants"); break; //LONG
12390 case COMBODSTRIKEREMNANTSTYPE: GET_COMBOCLASS_VAR_BYTE(strike_remnants_type, "StrikeRemnantsType"); break; //C
12391 case COMBODSTRIKECHANGE: GET_COMBOCLASS_VAR_INT(strike_change, "StrikeChange"); break; //LONG
12392 case COMBODSTRIKEITEM: GET_COMBOCLASS_VAR_DWORD(strike_item, "StrikeItem"); break; //SHORT
12393 case COMBODTOUCHITEM: GET_COMBOCLASS_VAR_DWORD(touch_item, "TouchItem"); break; //SHORT
12394 case COMBODTOUCHSTAIRS: GET_COMBOCLASS_VAR_BYTE(touch_stairs, "TouchStairs"); break; //C
12395 case COMBODTRIGGERTYPE: GET_COMBOCLASS_VAR_BYTE(trigger_type, "TriggerType"); break; //C
12396 case COMBODTRIGGERSENS: GET_COMBOCLASS_VAR_BYTE(trigger_sensitive, "TriggerSensitivity"); break; //C
12397 case COMBODWARPTYPE: GET_COMBOCLASS_VAR_BYTE(warp_type, "Warp"); break; //C
12398 case COMBODWARPSENS: GET_COMBOCLASS_VAR_BYTE(warp_sensitive, "WarpSensitivity"); break; //C
12399 case COMBODWARPDIRECT: GET_COMBOCLASS_VAR_BYTE(warp_direct, "WarpDirect"); break; //C
12400 case COMBODWARPLOCATION: GET_COMBOCLASS_VAR_BYTE(warp_location, "WarpLocation"); break; //C
12401 case COMBODWATER: GET_COMBOCLASS_VAR_BYTE(water, "Liquid"); break; //C
12402 case COMBODWHISTLE: GET_COMBOCLASS_VAR_BYTE(whistle, "Whistle"); break; //C
12403 case COMBODWINGAME: GET_COMBOCLASS_VAR_BYTE(win_game, "WinGame"); break; //C
12404 case COMBODBLOCKWPNLEVEL: GET_COMBOCLASS_VAR_BYTE(block_weapon_lvl, "BlockWeaponLevel"); break; //C
12405
12406
12407
12408 ///----------------------------------------------------------------------------------------------------//
12409 //npcdata nd-> variables
12410
12411 //npcdata nd->member variable
12412 #define GET_NPCDATA_VAR_INT32(member, str) \
12413 { \
12414 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
12415 { \
12416 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", str, (ri->npcdataref*10000)); \
12417 ret = -10000; \
12418 } \
12419 else \
12420 { \
12421 ret = (guysbuf[ri->npcdataref].member *10000); \
12422 } \
12423 } \
12424
12425 #define GET_NPCDATA_VAR_BYTE(member, str) \
12426 { \
12427 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
12428 { \
12429 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", str, (ri->npcdataref*10000)); \
12430 ret = -10000; \
12431 } \
12432 else \
12433 { \
12434 ret = (guysbuf[ri->npcdataref].member *10000); \
12435 } \
12436 } \
12437
12438 #define GET_NPCDATA_VAR_INT16(member, str) \
12439 { \
12440 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
12441 { \
12442 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", str, (ri->npcdataref*10000)); \
12443 ret = -10000; \
12444 } \
12445 else \
12446 { \
12447 ret = (guysbuf[ri->npcdataref].member *10000); \
12448 } \
12449 } \
12450
12451 #define GET_NPCDATA_VAR_INDEX(member, str, indexbound) \
12452 { \
12453 int32_t indx = ri->d[rINDEX] / 10000; \
12454 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
12455 { \
12456 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", str, (ri->npcdataref*10000)); \
12457 ret = -10000; \
12458 } \
12459 else if ( (unsigned)indx > indexbound ) \
12460 { \
12461 Z_scripterrlog("Invalid Array Index passed to npcdata->%s: %d\n", str, indx); \
12462 ret = -10000; \
12463 } \
12464 else \
12465 { \
12466 ret = (guysbuf[ri->npcdataref].member[indx] * 10000); \
12467 } \
12468 }
12469
12470 #define GET_NPCDATA_BYTE_INDEX(member, str, indexbound) \
12471 { \
12472 int32_t indx = ri->d[rINDEX] / 10000; \
12473 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
12474 { \
12475 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", str, (ri->npcdataref*10000)); \
12476 ret = -10000; \
12477 } \
12478 else if ( (unsigned)indx > indexbound ) \
12479 { \
12480 Z_scripterrlog("Invalid Array Index passed to npcdata->%s: %d\n", str, indx); \
12481 ret = -10000; \
12482 } \
12483 else \
12484 { \
12485 ret = (guysbuf[ri->npcdataref].member[indx] * 100000); \
12486 } \
12487 }
12488
12489 #define GET_NPCDATA_FLAG(member, str, indexbound) \
12490 { \
12491 int32_t flag = (value/10000); \
12492 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
12493 { \
12494 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", str, (ri->npcdataref*10000)); \
12495 } \
12496 else \
12497 { \
12498 ret = (guysbuf[ID].member&flag) ? 10000 : 0); \
12499 } \
12500 } \
12501
12502 case NPCDATATILE: GET_NPCDATA_VAR_BYTE(tile, "Tile"); break;
12503 case NPCDATAWIDTH: GET_NPCDATA_VAR_BYTE(width, "Width"); break;
12504 case NPCDATAHEIGHT: GET_NPCDATA_VAR_BYTE(height, "Height"); break;
12505 case NPCDATAFLAGS: GET_NPCDATA_VAR_INT16(flags, "Flags"); break; //16 b its
12506 case NPCDATAFLAGS2: GET_NPCDATA_VAR_INT16(flags2, "Flags2"); break; //16 bits
12507 case NPCDATASTILE: GET_NPCDATA_VAR_BYTE(s_tile, "STile"); break;
12508 case NPCDATASWIDTH: GET_NPCDATA_VAR_BYTE(s_width, "SWidth"); break;
12509 case NPCDATASHEIGHT: GET_NPCDATA_VAR_BYTE(s_height, "SHeight"); break;
12510 case NPCDATAETILE: GET_NPCDATA_VAR_INT32(e_tile, "ExTile"); break;
12511 case NPCDATAEWIDTH: GET_NPCDATA_VAR_BYTE(e_width, "ExWidth"); break;
12512 case NPCDATAEHEIGHT: GET_NPCDATA_VAR_BYTE(e_height, "ExHeight"); break;
12513 case NPCDATAHP: GET_NPCDATA_VAR_INT16(hp, "HP"); break;
12514 case NPCDATAFAMILY: GET_NPCDATA_VAR_INT16(family, "Family"); break;
12515 case NPCDATACSET: GET_NPCDATA_VAR_INT16(cset, "CSet"); break;
12516 case NPCDATAANIM: GET_NPCDATA_VAR_INT16(anim, "Anim"); break;
12517 case NPCDATAEANIM: GET_NPCDATA_VAR_INT16(e_anim, "ExAnim"); break;
12518 case NPCDATAFRAMERATE: GET_NPCDATA_VAR_INT16(frate, "Framerate"); break;
12519 case NPCDATAEFRAMERATE: GET_NPCDATA_VAR_INT16(e_frate, "ExFramerate"); break;
12520 case NPCDATATOUCHDAMAGE: GET_NPCDATA_VAR_INT16(dp, "TouchDamage"); break;
12521 case NPCDATAWEAPONDAMAGE: GET_NPCDATA_VAR_INT16(wdp, "WeaponDamage"); break;
12522 case NPCDATAWEAPON: GET_NPCDATA_VAR_INT16(weapon, "Weapon"); break;
12523 case NPCDATARANDOM: GET_NPCDATA_VAR_INT16(rate, "Random"); break;
12524 case NPCDATAHALT: GET_NPCDATA_VAR_INT16(hrate, "Haltrate"); break;
12525 case NPCDATASTEP: GET_NPCDATA_VAR_INT16(step, "Step"); break;
12526 case NPCDATAHOMING: GET_NPCDATA_VAR_INT16(homing, "Homing"); break;
12527 case NPCDATAHUNGER: GET_NPCDATA_VAR_INT16(grumble, "Hunger"); break;
12528 case NPCDATADROPSET: GET_NPCDATA_VAR_INT16(item_set, "Dropset"); break;
12529 case NPCDATABGSFX: GET_NPCDATA_VAR_INT16(bgsfx, "BGSFX"); break;
12530 case NPCDATADEATHSFX: GET_NPCDATA_VAR_BYTE(deadsfx, "DeathSFX"); break;
12531 case NPCDATAHITSFX: GET_NPCDATA_VAR_BYTE(hitsfx, "HitSFX"); break;
12532 case NPCDATAXOFS: GET_NPCDATA_VAR_INT32(xofs, "DrawXOffset"); break;
12533 case NPCDATAYOFS: GET_NPCDATA_VAR_INT32(yofs, "DrawYOffset"); break;
12534 case NPCDATAZOFS: GET_NPCDATA_VAR_INT32(zofs, "DrawZOffset"); break;
12535 case NPCDATAHXOFS: GET_NPCDATA_VAR_INT32(hxofs, "HitXOffset"); break;
12536 case NPCDATAHYOFS: GET_NPCDATA_VAR_INT32(hyofs, "HitYOffset"); break;
12537 case NPCDATAHITWIDTH: GET_NPCDATA_VAR_INT32(hxsz, "HitWidth"); break;
12538 case NPCDATAHITHEIGHT: GET_NPCDATA_VAR_INT32(hysz, "HitHeight"); break;
12539 case NPCDATAHITZ: GET_NPCDATA_VAR_INT32(hzsz, "HitZHeight"); break;
12540 case NPCDATASCRIPT: GET_NPCDATA_VAR_INT32(script, "Script"); break;
12541 case NPCDATATILEWIDTH: GET_NPCDATA_VAR_INT32(txsz, "TileWidth"); break;
12542 case NPCDATATILEHEIGHT: GET_NPCDATA_VAR_INT32(tysz, "TileHeight"); break;
12543 case NPCDATAWPNSPRITE: GET_NPCDATA_VAR_INT32(wpnsprite, "WeaponSprite"); break;
12544 case NPCDATAWEAPONSCRIPT: GET_NPCDATA_VAR_INT32(weaponscript, "WeaponScript"); break;
12545 case NPCDATADEFENSE: GET_NPCDATA_VAR_INDEX(defense, "Defense", 42); break;
12546 case NPCDATAINITD: GET_NPCDATA_VAR_INDEX(initD, "InitD", 8); break;
12547 case NPCDATAWEAPONINITD: GET_NPCDATA_VAR_INDEX(weap_initiald, "WeaponInitD", 8); break;
12548 case NPCDATASIZEFLAG: GET_NPCDATA_VAR_INT32(SIZEflags, "SizeFlags"); break;
12549
12550 case NPCDATAFROZENTILE: GET_NPCDATA_VAR_INT32(frozentile, "FrozenTile"); break;
12551 case NPCDATAFROZENCSET: GET_NPCDATA_VAR_INT32(frozencset, "FrozenCSet"); break;
12552
12553
12554 case NPCDATAATTRIBUTE:
12555 {
12556 int32_t indx = ri->d[rINDEX] / 10000;
12557 if(ri->npcdataref < 0 || ri->npcdataref > (MAXNPCS-1) )
12558 {
12559 Z_scripterrlog("Invalid Sprite ID passed to npcdata->Attributes[]: %d\n", (ri->npcdataref*10000));
12560 ret = -10000;
12561 }
12562 else if ( indx < 0 || indx > MAX_NPC_ATRIBUTES )
12563 {
12564 Z_scripterrlog("Invalid Array Index passed to npcdata->Attributes[]: %d\n", (ri->npcdataref*10000));
12565 ret = -10000;
12566 }
12567 else
12568 {
12569 switch(indx)
12570 {
12571 case 0: ret = (guysbuf[ri->npcdataref].misc1 * 10000); break;
12572 case 1: ret = (guysbuf[ri->npcdataref].misc2 * 10000); break;
12573 case 2: ret = (guysbuf[ri->npcdataref].misc3 * 10000); break;
12574 case 3: ret = (guysbuf[ri->npcdataref].misc4 * 10000); break;
12575 case 4: ret = (guysbuf[ri->npcdataref].misc5 * 10000); break;
12576 case 5: ret = (guysbuf[ri->npcdataref].misc6 * 10000); break;
12577 case 6: ret = (guysbuf[ri->npcdataref].misc7 * 10000); break;
12578 case 7: ret = (guysbuf[ri->npcdataref].misc8 * 10000); break;
12579 case 8: ret = (guysbuf[ri->npcdataref].misc9 * 10000); break;
12580 case 9: ret = (guysbuf[ri->npcdataref].misc10 * 10000); break;
12581 case 10: ret = (guysbuf[ri->npcdataref].misc11 * 10000); break;
12582 case 11: ret = (guysbuf[ri->npcdataref].misc12 * 10000); break;
12583 case 12: ret = (guysbuf[ri->npcdataref].misc13 * 10000); break;
12584 case 13: ret = (guysbuf[ri->npcdataref].misc14 * 10000); break;
12585 case 14: ret = (guysbuf[ri->npcdataref].misc15 * 10000); break;
12586 case 15: ret = (guysbuf[ri->npcdataref].misc16 * 10000); break;
12587 case 16: ret = (guysbuf[ri->npcdataref].misc17 * 10000); break;
12588 case 17: ret = (guysbuf[ri->npcdataref].misc18* 10000); break;
12589 case 18: ret = (guysbuf[ri->npcdataref].misc19 * 10000); break;
12590 case 19: ret = (guysbuf[ri->npcdataref].misc20 * 10000); break;
12591 case 20: ret = (guysbuf[ri->npcdataref].misc21 * 10000); break;
12592 case 21: ret = (guysbuf[ri->npcdataref].misc22 * 10000); break;
12593 case 22: ret = (guysbuf[ri->npcdataref].misc23 * 10000); break;
12594 case 23: ret = (guysbuf[ri->npcdataref].misc24 * 10000); break;
12595 case 24: ret = (guysbuf[ri->npcdataref].misc25 * 10000); break;
12596 case 25: ret = (guysbuf[ri->npcdataref].misc26 * 10000); break;
12597 case 26: ret = (guysbuf[ri->npcdataref].misc27 * 10000); break;
12598 case 27: ret = (guysbuf[ri->npcdataref].misc28 * 10000); break;
12599 case 28: ret = (guysbuf[ri->npcdataref].misc29 * 10000); break;
12600 case 29: ret = (guysbuf[ri->npcdataref].misc30 * 10000); break;
12601 case 30: ret = (guysbuf[ri->npcdataref].misc31 * 10000); break;
12602 case 31: ret = (guysbuf[ri->npcdataref].misc32 * 10000); break;
12603
12604
12605
12606 default:
12607 {
12608 Z_scripterrlog("Invalid Array Index passed to npcdata->Attributes[]: %d\n", (ri->npcdataref*10000));
12609 ret = -10000;
12610 break;
12611 }
12612 }
12613
12614 }
12615 break;
12616 }
12617
12618 case NPCDATABEHAVIOUR:
12619 {
12620 if(ri->npcdataref < 0 || ri->npcdataref > (MAXNPCS-1) )
12621 {
12622 ret = -10000;
12623 break;
12624 }
12625 int32_t index = vbound(ri->d[rINDEX]/10000,0,4);
12626 switch(index)
12627 {
12628 case 0:
12629 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG1)?10000:0; break;
12630 case 1:
12631 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG2)?10000:0; break;
12632 case 2:
12633 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG3)?10000:0; break;
12634 case 3:
12635 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG4)?10000:0; break;
12636 case 4:
12637 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG5)?10000:0; break;
12638 case 5:
12639 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG6)?10000:0; break;
12640 case 6:
12641 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG7)?10000:0; break;
12642 case 7:
12643 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG8)?10000:0; break;
12644 case 8:
12645 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG9)?10000:0; break;
12646 case 9:
12647 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG10)?10000:0; break;
12648 case 10:
12649 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG11)?10000:0; break;
12650 case 11:
12651 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG12)?10000:0; break;
12652 case 12:
12653 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG13)?10000:0; break;
12654 case 13:
12655 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG14)?10000:0; break;
12656 case 14:
12657 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG15)?10000:0; break;
12658 case 15:
12659 ret=(guysbuf[ri->npcdataref].editorflags & ENEMY_FLAG16)?10000:0; break;
12660
12661
12662 default:
12663 ret = 0; break;
12664 }
12665
12666 break;
12667 }
12668
12669 case NPCDATASHIELD:
12670 {
12671 int32_t indx = ri->d[rINDEX] / 10000;
12672 if(ri->npcdataref < 0 || ri->npcdataref > (MAXNPCS-1) )
12673 {
12674 Z_scripterrlog("Invalid NPC ID passed to npcdata->Shield[]: %d\n", (ri->npcdataref*10000));
12675 ret = -10000;
12676 break;
12677 }
12678 else
12679 {
12680 switch(indx)
12681 {
12682 case 0:
12683 {
12684 ret = ((guysbuf[ri->npcdataref].flags&inv_front) ? 10000 : 0);
12685 break;
12686 }
12687 case 1:
12688 {
12689 ret = ((guysbuf[ri->npcdataref].flags&inv_left) ? 10000 : 0);
12690 break;
12691 }
12692 case 2:
12693 {
12694 ret = ((guysbuf[ri->npcdataref].flags&inv_right) ? 10000 : 0);
12695 break;
12696 }
12697 case 3:
12698 {
12699 ret = ((guysbuf[ri->npcdataref].flags&inv_back) ? 10000 : 0);
12700 break;
12701 }
12702 case 4:
12703 {
12704 ret = ((guysbuf[ri->npcdataref].flags&guy_bkshield) ? 10000 : 0);
12705 break;
12706 }
12707 default:
12708 {
12709 Z_scripterrlog("Invalid Array Index passed to npcdata->Shield[]: %d\n", indx);
12710 ret = -10000;
12711 break;
12712 }
12713 }
12714 }
12715 }
12716 break;
12717
12718 case NPCDSHADOWSPR:
12719 {
12720 if(ri->npcdataref < 0 || ri->npcdataref > (MAXNPCS-1) )
12721 {
12722 Z_scripterrlog("Invalid NPC ID passed to npcdata->ShadowSprite: %d\n", (ri->npcdataref*10000));
12723 ret = -10000;
12724 }
12725 else
12726 {
12727 ret = guysbuf[ri->npcdataref].spr_shadow * 10000;
12728 }
12729 break;
12730 }
12731 case NPCDSPAWNSPR:
12732 {
12733 if(ri->npcdataref < 0 || ri->npcdataref > (MAXNPCS-1) )
12734 {
12735 Z_scripterrlog("Invalid NPC ID passed to npcdata->SpawnSprite: %d\n", (ri->npcdataref*10000));
12736 ret = -10000;
12737 }
12738 else
12739 {
12740 ret = guysbuf[ri->npcdataref].spr_spawn * 10000;
12741 }
12742 break;
12743 }
12744 case NPCDDEATHSPR:
12745 {
12746 if(ri->npcdataref < 0 || ri->npcdataref > (MAXNPCS-1) )
12747 {
12748 Z_scripterrlog("Invalid NPC ID passed to npcdata->DeathSprite: %d\n", (ri->npcdataref*10000));
12749 ret = -10000;
12750 }
12751 else
12752 {
12753 ret = guysbuf[ri->npcdataref].spr_death * 10000;
12754 }
12755 break;
12756 }
12757
12758 case NPCMATCHINITDLABEL: //Same form as SetScreenD()
12759 //bool npcdata->MatchInitDLabel("label", d)
12760 {
12761
12762 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
12763 {
12764 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", (ri->npcdataref*10000), "MatchInitDLabel()");
12765 ret = 0;
12766 break;
12767 }
12768
12769 int32_t arrayptr = get_register(sarg1) / 10000;
12770 int32_t init_d_index = get_register(sarg2) / 10000;
12771
12772 string name;
12773 ArrayH::getString(arrayptr, name, 256); // What's the limit on name length?
12774
12775 bool match = (!( strcmp(name.c_str(), guysbuf[ri->npcdataref].initD_label[init_d_index] )));
12776
12777 ret = ( match ? 10000 : 0 );
12778 break;
12779 }
12780
12781 ///----------------------------------------------------------------------------------------------------//
12782 //Dropset Variables
12783
12784 case DROPSETITEMS:
12785 {
12786 if(ri->dropsetref < 0 || ri->dropsetref > MAXITEMDROPSETS)
12787 {
12788 Z_scripterrlog("Invalid dropset pointer %d\n", ri->dropsetref);
12789 ret = -10000;
12790 break;
12791 }
12792 int32_t indx = ri->d[rINDEX]/10000;
12793 if(indx < 0 || indx > 9)
12794 {
12795 Z_scripterrlog("Invalid index passed to dropdata->Items[]: %d\n", indx);
12796 ret = -10000;
12797 }
12798 else
12799 {
12800 ret = item_drop_sets[ri->dropsetref].item[indx] * 10000;
12801 }
12802 break;
12803 }
12804 case DROPSETCHANCES:
12805 {
12806 if(ri->dropsetref < 0 || ri->dropsetref > MAXITEMDROPSETS)
12807 {
12808 Z_scripterrlog("Invalid dropset pointer %d\n", ri->dropsetref);
12809 ret = -10000;
12810 break;
12811 }
12812 int32_t indx = ri->d[rINDEX]/10000;
12813 if(indx < 0 || indx > 9)
12814 {
12815 Z_scripterrlog("Invalid index passed to dropdata->Chances[]: %d\n", indx);
12816 ret = -10000;
12817 }
12818 else
12819 {
12820 ret = item_drop_sets[ri->dropsetref].chance[indx+1] * 10000; //+1 is because '0' is 'nothing''s chance
12821 }
12822 break;
12823 }
12824 case DROPSETNULLCHANCE:
12825 {
12826 if(ri->dropsetref < 0 || ri->dropsetref > MAXITEMDROPSETS)
12827 {
12828 Z_scripterrlog("Invalid dropset pointer %d\n", ri->dropsetref);
12829 ret = -10000;
12830 break;
12831 }
12832 ret = item_drop_sets[ri->dropsetref].chance[0] * 10000;
12833 break;
12834 }
12835 case DROPSETCHOOSE:
12836 {
12837 if(ri->dropsetref < 0 || ri->dropsetref > MAXITEMDROPSETS)
12838 {
12839 Z_scripterrlog("Invalid dropset pointer %d\n", ri->dropsetref);
12840 ret = -10000;
12841 break;
12842 }
12843 ret = select_dropitem(ri->dropsetref) * 10000;
12844 break;
12845 }
12846
12847 ///----------------------------------------------------------------------------------------------------//
12848 //Audio Variables
12849
12850 case AUDIOVOLUME:
12851 {
12852 int32_t indx = ri->d[rINDEX] / 10000;
12853 switch(indx)
12854 {
12855
12856 case 0: //midi volume
12857 {
12858 ret = FFScript::do_getMIDI_volume() * 10000;
12859 break;
12860 }
12861 case 1: //digi volume
12862 {
12863 ret = FFScript::do_getDIGI_volume() * 10000;
12864 break;
12865 }
12866 case 2: //emh music volume
12867 {
12868 ret = FFScript::do_getMusic_volume() * 10000;
12869 break;
12870 }
12871 case 3: //sfx volume
12872 {
12873 ret = FFScript::do_getSFX_volume() * 10000;
12874 break;
12875 }
12876 default:
12877 {
12878 Z_scripterrlog("Attempted to access an invalid index of Audio->Volume[]", indx);
12879 ret = -10000;
12880 break;
12881 }
12882 }
12883 }
12884 break;
12885
12886 case AUDIOPAN:
12887 {
12888 ret = FFScript::do_getSFX_pan() * 10000;
12889 break;
12890 }
12891
12892 ///----------------------------------------------------------------------------------------------------//
12893 //Graphics->
12894
12895 case NUMDRAWS:
12896 ret = script_drawing_commands.Count() * 10000;
12897 //ret = FFCore.numscriptdraws * 10000; // This isn't updated until end of frame, making it useless!
12898 break;
12899
12900 case MAXDRAWS:
12901 ret = MAX_SCRIPT_DRAWING_COMMANDS * 10000;
12902 break;
12903
12904 case ISBLANKTILE: ret = (FFCore.IsBlankTile(ri->d[rINDEX]/10000) * 10000); break;
12905
12906 case BITMAPWIDTH:
12907 {
12908 //if ( scb.script_created_bitmaps[ri->bitmapref].u_bmp )
12909 //{
12910 // ret = scb.script_created_bitmaps[ri->bitmapref].u_bmp->w * 10000;
12911 //}
12912 //else ret = 0;
12913 ret = scb.script_created_bitmaps[ri->bitmapref-10].width * 10000;
12914 break;
12915 }
12916
12917 case BITMAPHEIGHT:
12918 {
12919 //Z_scripterrlog("BITMAPHEI|GHT ri->BitmapRef is %d\n", ri->bitmapref);
12920 //Z_scripterrlog("ref bitmap height: %d\n", scb.script_created_bitmaps[ri->bitmapref-10].u_bmp->h);
12921 //if ( scb.script_created_bitmaps[ri->bitmapref].u_bmp )
12922 //{
12923 // ret = scb.script_created_bitmaps[ri->bitmapref].u_bmp->h * 10000;
12924 //}
12925 //else ret = 0;
12926 ret = scb.script_created_bitmaps[ri->bitmapref-10].height * 10000;
12927 break;
12928 }
12929 ///----------------------------------------------------------------------------------------------------//
12930 //File->
12931 case FILEPOS:
12932 {
12933 if(user_file* f = checkFile(ri->fileref, "Pos", true))
12934 {
12935 ret = ftell(f->file); //NOT *10000 -V
12936 }
12937 else ret = -10000L;
12938 break;
12939 }
12940 case FILEEOF:
12941 {
12942 if(user_file* f = checkFile(ri->fileref, "EOF", true))
12943 {
12944 ret = feof(f->file) ? 10000L : 0L; //Boolean
12945 }
12946 else ret = -10000L;
12947 break;
12948 }
12949 case FILEERR:
12950 {
12951 if(user_file* f = checkFile(ri->fileref, "Error", true))
12952 {
12953 ret = ferror(f->file) * 10000L;
12954 }
12955 else ret = -10000L;
12956 break;
12957 }
12958
12959 ///----------------------------------------------------------------------------------------------------//
12960 //Directory->
12961 case DIRECTORYSIZE:
12962 {
12963 if(user_dir* dr = checkDir(ri->directoryref, "Size()", true))
12964 {
12965 ret = dr->size() * 10000L;
12966 }
12967 else ret = -10000L;
12968 break;
12969 }
12970
12971 ///----------------------------------------------------------------------------------------------------//
12972 //Stack->
12973 case STACKSIZE:
12974 {
12975 if(user_stack* st = checkStack(ri->stackref, "Size", true))
12976 {
12977 ret = st->size(); //NOT *10000
12978 }
12979 else ret = -10000L;
12980 break;
12981 }
12982 case STACKFULL:
12983 {
12984 if(user_stack* st = checkStack(ri->stackref, "Full", true))
12985 {
12986 ret = st->full() ? 10000L : 0L;
12987 }
12988 else ret = -10000L;
12989 break;
12990 }
12991
12992 ///----------------------------------------------------------------------------------------------------//
12993 //Module->
12994
12995 case MODULEGETINT:
12996 {
12997 int32_t section_pointer = ((ri->d[rINDEX])/10000);
12998 int32_t element_pointer = ((ri->d[rINDEX2])/10000);
12999 string sectionid;
13000 string elementid;
13001
13002 ArrayH::getString(section_pointer, sectionid);
13003 ArrayH::getString(element_pointer, elementid);
13004
13005 ///set config file
13006 if(!fileexists((char*)moduledata.module_name))
13007 {
13008 Z_scripterrlog("I/O Error: No module definitions found when using Module->GetInt()\n");
13009 ret = -10000;
13010 }
13011 else
13012 {
13013 zc_push_config();
13014 zc_config_file(moduledata.module_name);
13015 ret = zc_get_config_basic(sectionid.c_str(), elementid.c_str(), 0)*10000;
13016 //return config file to zc.cfg
13017 zc_pop_config();
13018 }
13019 break;
13020 }
13021
13022 ///----------------------------------------------------------------------------------------------------//
13023 //Misc./Internal
13024 case REFFFC:
13025 15654 ret = ri->ffcref * 10000;
13026 15654 break;
13027
13028 case REFITEM:
13029 158257 ret = ri->itemref;
13030 158257 break;
13031
13032 case REFITEMCLASS:
13033 56823 ret = ri->idata;
13034 56823 break;
13035
13036 case REFLWPN:
13037 1340206 ret = ri->lwpn;
13038 1340206 break;
13039
13040 case REFEWPN:
13041 2886839 ret = ri->ewpn;
13042 2886839 break;
13043
13044 case REFNPC:
13045 15644160 ret = ri->guyref;
13046 15644160 break;
13047
13048 case REFMAPDATA: ret = ri->mapsref; break;
13049 case REFSCREENDATA: ret = ri->screenref; break;
13050 25786 case REFCOMBODATA: ret = ri->combosref; break;
13051 case REFSPRITEDATA: ret = ri->spritesref; break;
13052 case REFBITMAP: ret = ri->bitmapref; break;
13053 case REFNPCCLASS: ret = ri->npcdataref; break;
13054
13055
13056 755060 case REFDMAPDATA: ret = ri->dmapsref; break;
13057 case REFSHOPDATA: ret = ri->shopsref; break;
13058 case REFMSGDATA: ret = ri->zmsgref; break;
13059 case REFUNTYPED: ret = ri->untypedref; break;
13060
13061 case REFDROPS: ret = ri->dropsetref; break;
13062 case REFBOTTLETYPE: ret = ri->bottletyperef; break;
13063 case REFBOTTLESHOP: ret = ri->bottleshopref; break;
13064 427 case REFGENERICDATA: ret = ri->genericdataref; break;
13065 case REFPONDS: ret = ri->pondref; break;
13066 case REFWARPRINGS: ret = ri->warpringref; break;
13067 case REFDOORS: ret = ri->doorsref; break;
13068 case REFUICOLOURS: ret = ri->zcoloursref; break;
13069 case REFRGB: ret = ri->rgbref; break;
13070 case REFPALETTE: ret = ri->paletteref; break;
13071 case REFTUNES: ret = ri->tunesref; break;
13072 case REFPALCYCLE: ret = ri->palcycleref; break;
13073 case REFGAMEDATA: ret = ri->gamedataref; break;
13074 case REFCHEATS: ret = ri->cheatsref; break;
13075 case REFFILE: ret = ri->fileref; break;
13076 case REFDIRECTORY: ret = ri->directoryref; break;
13077 case REFSTACK: ret = ri->stackref; break;
13078 case REFSUBSCREEN: ret = ri->subscreenref; break;
13079 case REFRNG: ret = ri->rngref; break;
13080 case CLASS_THISKEY: ret = ri->thiskey; break;
13081 case CLASS_THISKEY2: ret = ri->thiskey2; break;
13082 case REFPALDATA: ret = ri->paldataref; break;
13083
13084
13085 case SP:
13086 ret = ri->sp * 10000;
13087 break;
13088
13089 case PC:
13090 ret = ri->pc;
13091 break;
13092
13093 case SWITCHKEY:
13094 ret = ri->switchkey;
13095 break;
13096
13097 case SCRIPTRAM:
13098 case GLOBALRAM:
13099 952310006 ret = ArrayH::getElement(ri->d[rINDEX] / 10000, ri->d[rINDEX2] / 10000);
13100 952310006 break;
13101
13102 case SCRIPTRAMD:
13103 case GLOBALRAMD:
13104 ret = ArrayH::getElement(ri->d[rINDEX] / 10000, 0);
13105 break;
13106
13107 case GDD://Doesn't work like this =(
13108 ret = game->global_d[ri->d[rINDEX] / 10000];
13109 break;
13110
13111 ///----------------------------------------------------------------------------------------------------//
13112
13113 case PALDATACOLOR:
13114 {
13115 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->GetColor()"))
13116 {
13117 int32_t ind = ri->d[rINDEX] / 10000; // get_register(sarg1) / 10000;
13118 if (unsigned(ind) >= PALDATA_NUM_COLORS)
13119 {
13120 Z_scripterrlog("Invalid color index (%d) passed to paldata->GetColor(). Valid indices are 0-255.\n", ind);
13121 ret = -10000;
13122 break;
13123 }
13124
13125 if (get_bit(pd->colors_used, ind))
13126 {
13127 RGB c = pd->colors[ind];
13128
13129 ret = (c.r << 16) | (c.g << 8) | c.b;
13130 }
13131 else
13132 {
13133 //Z_scripterrlog("Color index (%d) returned an invalid color in paldata->GetColor().\n", ind);
13134 ret = -10000;
13135 break;
13136 }
13137 }
13138 break;
13139 }
13140 case PALDATAR:
13141 ret = FFCore.do_paldata_getrgb(0);
13142 break;
13143 case PALDATAG:
13144 ret = FFCore.do_paldata_getrgb(1);
13145 break;
13146 case PALDATAB:
13147 ret = FFCore.do_paldata_getrgb(2);
13148 break;
13149
13150 ///----------------------------------------------------------------------------------------------------//
13151
13152 case GENDATARUNNING:
13153 {
13154 ret = 0;
13155 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "Running"))
13156 {
13157 ret = scr->doscript ? 10000L : 0L;
13158 }
13159 break;
13160 }
13161 case GENDATASIZE:
13162 {
13163 ret = 0;
13164 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "DataSize"))
13165 {
13166 ret = scr->dataSize()*10000;
13167 }
13168 break;
13169 }
13170 case GENDATAEXITSTATE:
13171 {
13172 ret = 0;
13173 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "ExitState"))
13174 {
13175 size_t indx = ri->d[rINDEX]/10000;
13176 if(indx >= GENSCR_NUMST)
13177 {
13178 Z_scripterrlog("Invalid index passed to genericdata->ExitState[]: %d\n", indx);
13179 break;
13180 }
13181 ret = (scr->exitState & (1<<indx)) ? 10000L : 0;
13182 }
13183 break;
13184 }
13185 case GENDATARELOADSTATE:
13186 {
13187 ret = 0;
13188 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "ReloadState"))
13189 {
13190 size_t indx = ri->d[rINDEX]/10000;
13191 if(indx >= GENSCR_NUMST)
13192 {
13193 Z_scripterrlog("Invalid index passed to genericdata->ReloadState[]: %d\n", indx);
13194 break;
13195 }
13196 ret = (scr->reloadState & (1<<indx)) ? 10000L : 0;
13197 }
13198 break;
13199 }
13200 case GENDATAEVENTSTATE:
13201 {
13202 ret = 0;
13203 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "EventListen"))
13204 {
13205 size_t indx = ri->d[rINDEX]/10000;
13206 if(indx >= GENSCR_NUMEVENT)
13207 {
13208 Z_scripterrlog("Invalid index passed to genericdata->EventListen[]: %d\n", indx);
13209 break;
13210 }
13211 ret = (scr->eventstate & (1<<indx)) ? 10000L : 0;
13212 }
13213 break;
13214 }
13215 case GENDATADATA:
13216 {
13217 ret = 0;
13218 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "Data[]"))
13219 {
13220 size_t indx = ri->d[rINDEX]/10000;
13221 if(indx >= scr->dataSize())
13222 {
13223 Z_scripterrlog("Invalid index passed to genericdata->Data[]: %d\n", indx);
13224 break;
13225 }
13226 ret = scr->data[indx];
13227 }
13228 break;
13229 }
13230 case GENDATAINITD:
13231 {
13232 ret = 0;
13233 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "InitD[]"))
13234 {
13235 size_t indx = ri->d[rINDEX]/10000;
13236 if(indx >= 8)
13237 {
13238 Z_scripterrlog("Invalid index passed to genericdata->InitD[]: %d\n", indx);
13239 break;
13240 }
13241 ret = scr->initd[indx];
13242 }
13243 break;
13244 }
13245
13246 ///----------------------------------------------------------------------------------------------------//
13247
13248 case PORTALX:
13249 {
13250 ret = -10000;
13251 if(portal* p = checkPortal(ri->portalref, "X"))
13252 ret = p->x.getZLong();
13253 break;
13254 }
13255 case PORTALY:
13256 {
13257 ret = -10000;
13258 if(portal* p = checkPortal(ri->portalref, "Y"))
13259 ret = p->y.getZLong();
13260 break;
13261 }
13262 case PORTALDMAP:
13263 {
13264 ret = -10000;
13265 if(portal* p = checkPortal(ri->portalref, "DMap"))
13266 ret = p->destdmap*10000;
13267 break;
13268 }
13269 case PORTALSCREEN:
13270 {
13271 ret = -10000;
13272 if(portal* p = checkPortal(ri->portalref, "Screen"))
13273 ret = p->destscr*10000;
13274 break;
13275 }
13276 case PORTALACLK:
13277 {
13278 ret = -10000;
13279 if(portal* p = checkPortal(ri->portalref, "AClk"))
13280 ret = p->aclk*10000;
13281 break;
13282 }
13283 case PORTALAFRM:
13284 {
13285 ret = -10000;
13286 if(portal* p = checkPortal(ri->portalref, "AFrame"))
13287 ret = p->aframe*10000;
13288 break;
13289 }
13290 case PORTALOTILE:
13291 {
13292 ret = -10000;
13293 if(portal* p = checkPortal(ri->portalref, "OriginalTile"))
13294 ret = p->o_tile*10000;
13295 break;
13296 }
13297 case PORTALASPD:
13298 {
13299 ret = -10000;
13300 if(portal* p = checkPortal(ri->portalref, "ASpeed"))
13301 ret = p->aspd*10000;
13302 break;
13303 }
13304 case PORTALFRAMES:
13305 {
13306 ret = -10000;
13307 if(portal* p = checkPortal(ri->portalref, "Frames"))
13308 ret = p->frames*10000;
13309 break;
13310 }
13311 case PORTALSAVED:
13312 {
13313 ret = 0;
13314 if(portal* p = checkPortal(ri->portalref, "SavedPortal"))
13315 ret = p->saved_data;
13316 break;
13317 }
13318 case PORTALCLOSEDIS:
13319 {
13320 ret = 0;
13321 if(portal* p = checkPortal(ri->portalref, "CloseDisabled"))
13322 ret = p->prox_active ? 0 : 10000; //Inverted
13323 break;
13324 }
13325 case REFPORTAL:
13326 {
13327 ret = ri->portalref;
13328 break;
13329 }
13330 case REFSAVPORTAL:
13331 {
13332 ret = ri->saveportalref;
13333 break;
13334 }
13335 case PORTALWARPSFX:
13336 {
13337 ret = 0;
13338 if(portal* p = checkPortal(ri->portalref, "WarpSFX"))
13339 ret = p->wsfx ? 0 : 10000;
13340 break;
13341 }
13342 case PORTALWARPVFX:
13343 {
13344 ret = 0;
13345 if(portal* p = checkPortal(ri->portalref, "WarpEffect"))
13346 ret = p->weffect ? 0 : 10000;
13347 break;
13348 }
13349 case SAVEDPORTALX:
13350 {
13351 ret = -10000;
13352 if(savedportal* p = checkSavedPortal(ri->saveportalref, "X"))
13353 ret = p->x;
13354 break;
13355 }
13356 case SAVEDPORTALY:
13357 {
13358 ret = -10000;
13359 if(savedportal* p = checkSavedPortal(ri->saveportalref, "Y"))
13360 ret = p->y;
13361 break;
13362 }
13363 case SAVEDPORTALSRCDMAP:
13364 {
13365 ret = -10000;
13366 if(savedportal* p = checkSavedPortal(ri->saveportalref, "SrcDMap"))
13367 ret = p->srcdmap * 10000;
13368 break;
13369 }
13370 case SAVEDPORTALDESTDMAP:
13371 {
13372 ret = -10000;
13373 if(savedportal* p = checkSavedPortal(ri->saveportalref, "DestDMap"))
13374 ret = p->destdmap * 10000;
13375 break;
13376 }
13377 case SAVEDPORTALSRCSCREEN:
13378 {
13379 ret = -10000;
13380 if(savedportal* p = checkSavedPortal(ri->saveportalref, "SrcScreen"))
13381 ret = p->srcscr * 10000;
13382 break;
13383 }
13384 case SAVEDPORTALDSTSCREEN:
13385 {
13386 ret = -10000;
13387 if(savedportal* p = checkSavedPortal(ri->saveportalref, "DestScreen"))
13388 ret = p->destscr * 10000;
13389 break;
13390 }
13391 case SAVEDPORTALWARPSFX:
13392 {
13393 ret = -10000;
13394 if(savedportal* p = checkSavedPortal(ri->saveportalref, "WarpSFX"))
13395 ret = p->sfx * 10000;
13396 break;
13397 }
13398 case SAVEDPORTALWARPVFX:
13399 {
13400 ret = -10000;
13401 if(savedportal* p = checkSavedPortal(ri->saveportalref, "WarpEffect"))
13402 ret = p->warpfx * 10000;
13403 break;
13404 }
13405 case SAVEDPORTALSPRITE:
13406 {
13407 ret = -10000;
13408 if(savedportal* p = checkSavedPortal(ri->saveportalref, "Sprite"))
13409 ret = p->spr * 10000;
13410 break;
13411 }
13412 case SAVEDPORTALPORTAL:
13413 {
13414 ret = 0;
13415 if(savedportal* p = checkSavedPortal(ri->saveportalref, "Portal"))
13416 ret = getPortalFromSaved(p);
13417 break;
13418 }
13419 case PORTALCOUNT:
13420 {
13421 ret = portals.Count()*10000;
13422 break;
13423 }
13424 case SAVEDPORTALCOUNT:
13425 {
13426 ret = game->user_portals.size()*10000;
13427 break;
13428 }
13429
13430
13431 default:
13432 {
13433
2/4
✓ Branch 0 taken 749214842 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 749214842 times.
749214842 if(arg >= D(0) && arg <= D(7)) ret = ri->d[arg - D(0)];
13434 else if(arg >= A(0) && arg <= A(1)) ret = ri->a[arg - A(0)];
13435 else if(arg >= GD(0) && arg <= GD(MAX_SCRIPT_REGISTERS)) ret = game->global_d[arg - GD(0)];
13436
13437 749214842 break;
13438 }
13439 }
13440
13441
1/2
✓ Branch 0 taken 2760569860 times.
✗ Branch 1 not taken.
2760569860 if ( zasm_debugger ) FFCore.ZASMPrintVarGet(arg, ret);
13442 2760569860 return ret;
13443 }
13444
13445 //Setter Instructions
13446
13447
13448 1398816198 void set_register(int32_t arg, int32_t value)
13449 {
13450
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1398816198 times.
1398816198 if ( zasm_debugger ) FFCore.ZASMPrintVarSet(arg, value);
13451 //Macros
13452
13453 #define SET_SPRITEDATA_VAR_INT(member, str) \
13454 { \
13455 if(unsigned(ri->spritesref) > (MAXWPNS-1) ) \
13456 { \
13457 Z_scripterrlog("Invalid Sprite ID passed to spritedata->%s: %d\n", str, (ri->spritesref*10000)); \
13458 } \
13459 else \
13460 { \
13461 wpnsbuf[ri->spritesref].member = vbound((value / 10000),0,214747); \
13462 } \
13463 } \
13464
13465 #define SET_SPRITEDATA_VAR_BYTE(member, str) \
13466 { \
13467 if(unsigned(ri->spritesref) > (MAXWPNS-1) ) \
13468 { \
13469 Z_scripterrlog("Invalid Sprite ID passed to spritedata->%s: %d\n", str, (ri->spritesref*10000)); \
13470 } \
13471 else \
13472 { \
13473 wpnsbuf[ri->spritesref].member = vbound((value / 10000),0,255); \
13474 } \
13475 } \
13476
13477
239/1194
✓ Branch 0 taken 1215785 times.
✓ Branch 1 taken 9444 times.
✓ Branch 2 taken 9428 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9172 times.
✓ Branch 5 taken 3250 times.
✓ Branch 6 taken 1532 times.
✓ Branch 7 taken 56626 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 78737 times.
✓ Branch 13 taken 222649 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 20 taken 787 times.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✓ Branch 23 taken 193733 times.
✓ Branch 24 taken 1469 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✓ Branch 29 taken 4552 times.
✗ Branch 30 not taken.
✓ Branch 31 taken 234661 times.
✓ Branch 32 taken 234074 times.
✓ Branch 33 taken 910117 times.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✓ Branch 36 taken 21219 times.
✓ Branch 37 taken 2612168 times.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✓ Branch 41 taken 1 times.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✓ Branch 46 taken 88964 times.
✓ Branch 47 taken 551 times.
✗ Branch 48 not taken.
✓ Branch 49 taken 131 times.
✗ Branch 50 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 53 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
✗ Branch 56 not taken.
✗ Branch 57 not taken.
✗ Branch 58 not taken.
✗ Branch 59 not taken.
✗ Branch 60 not taken.
✗ Branch 61 not taken.
✓ Branch 62 taken 455505918 times.
✗ Branch 63 not taken.
✗ Branch 64 not taken.
✓ Branch 65 taken 261416152 times.
✗ Branch 66 not taken.
✓ Branch 67 taken 2270014 times.
✓ Branch 68 taken 9724 times.
✓ Branch 69 taken 1041229 times.
✓ Branch 70 taken 2881 times.
✓ Branch 71 taken 1213780 times.
✓ Branch 72 taken 9172 times.
✓ Branch 73 taken 229038 times.
✓ Branch 74 taken 3248 times.
✓ Branch 75 taken 9502 times.
✓ Branch 76 taken 9512 times.
✓ Branch 77 taken 616 times.
✓ Branch 78 taken 900 times.
✓ Branch 79 taken 17706 times.
✗ Branch 80 not taken.
✗ Branch 81 not taken.
✓ Branch 82 taken 444601 times.
✗ Branch 83 not taken.
✓ Branch 84 taken 458940 times.
✓ Branch 85 taken 2769 times.
✓ Branch 86 taken 64379 times.
✗ Branch 87 not taken.
✓ Branch 88 taken 93694 times.
✗ Branch 89 not taken.
✗ Branch 90 not taken.
✗ Branch 91 not taken.
✓ Branch 92 taken 270553 times.
✓ Branch 93 taken 10415 times.
✓ Branch 94 taken 56 times.
✗ Branch 95 not taken.
✓ Branch 96 taken 388 times.
✗ Branch 97 not taken.
✗ Branch 98 not taken.
✗ Branch 99 not taken.
✗ Branch 100 not taken.
✓ Branch 101 taken 5906 times.
✗ Branch 102 not taken.
✗ Branch 103 not taken.
✓ Branch 104 taken 740 times.
✗ Branch 105 not taken.
✓ Branch 106 taken 4 times.
✓ Branch 107 taken 5161 times.
✗ Branch 108 not taken.
✗ Branch 109 not taken.
✗ Branch 110 not taken.
✗ Branch 111 not taken.
✗ Branch 112 not taken.
✗ Branch 113 not taken.
✗ Branch 114 not taken.
✓ Branch 115 taken 280560 times.
✗ Branch 116 not taken.
✗ Branch 117 not taken.
✗ Branch 118 not taken.
✗ Branch 119 not taken.
✗ Branch 120 not taken.
✗ Branch 121 not taken.
✗ Branch 122 not taken.
✗ Branch 123 not taken.
✗ Branch 124 not taken.
✗ Branch 125 not taken.
✗ Branch 126 not taken.
✓ Branch 127 taken 93758 times.
✓ Branch 128 taken 93759 times.
✓ Branch 129 taken 93772 times.
✓ Branch 130 taken 93778 times.
✗ Branch 131 not taken.
✗ Branch 132 not taken.
✗ Branch 133 not taken.
✗ Branch 134 not taken.
✗ Branch 135 not taken.
✓ Branch 136 taken 2569 times.
✗ Branch 137 not taken.
✓ Branch 138 taken 2569 times.
✗ Branch 139 not taken.
✗ Branch 140 not taken.
✗ Branch 141 not taken.
✗ Branch 142 not taken.
✗ Branch 143 not taken.
✗ Branch 144 not taken.
✗ Branch 145 not taken.
✗ Branch 146 not taken.
✗ Branch 147 not taken.
✗ Branch 148 not taken.
✗ Branch 149 not taken.
✗ Branch 150 not taken.
✓ Branch 151 taken 166 times.
✗ Branch 152 not taken.
✗ Branch 153 not taken.
✗ Branch 154 not taken.
✗ Branch 155 not taken.
✗ Branch 156 not taken.
✗ Branch 157 not taken.
✗ Branch 158 not taken.
✗ Branch 159 not taken.
✗ Branch 160 not taken.
✗ Branch 161 not taken.
✗ Branch 162 not taken.
✗ Branch 163 not taken.
✗ Branch 164 not taken.
✗ Branch 165 not taken.
✗ Branch 166 not taken.
✓ Branch 167 taken 928305 times.
✓ Branch 168 taken 461890 times.
✓ Branch 169 taken 249228 times.
✓ Branch 170 taken 249220 times.
✓ Branch 171 taken 236658 times.
✓ Branch 172 taken 236880 times.
✓ Branch 173 taken 89166 times.
✓ Branch 174 taken 76223 times.
✓ Branch 175 taken 78784 times.
✓ Branch 176 taken 222649 times.
✓ Branch 177 taken 222649 times.
✓ Branch 178 taken 222649 times.
✓ Branch 179 taken 222649 times.
✗ Branch 180 not taken.
✗ Branch 181 not taken.
✗ Branch 182 not taken.
✗ Branch 183 not taken.
✓ Branch 184 taken 928305 times.
✓ Branch 185 taken 461890 times.
✓ Branch 186 taken 218369 times.
✓ Branch 187 taken 218364 times.
✓ Branch 188 taken 218431 times.
✓ Branch 189 taken 218461 times.
✓ Branch 190 taken 83086 times.
✓ Branch 191 taken 70141 times.
✓ Branch 192 taken 75869 times.
✓ Branch 193 taken 75916 times.
✓ Branch 194 taken 222649 times.
✓ Branch 195 taken 222649 times.
✓ Branch 196 taken 222649 times.
✗ Branch 197 not taken.
✗ Branch 198 not taken.
✗ Branch 199 not taken.
✗ Branch 200 not taken.
✗ Branch 201 not taken.
✗ Branch 202 not taken.
✓ Branch 203 taken 281176 times.
✓ Branch 204 taken 281262 times.
✗ Branch 205 not taken.
✗ Branch 206 not taken.
✗ Branch 207 not taken.
✗ Branch 208 not taken.
✗ Branch 209 not taken.
✗ Branch 210 not taken.
✗ Branch 211 not taken.
✗ Branch 212 not taken.
✗ Branch 213 not taken.
✗ Branch 214 not taken.
✗ Branch 215 not taken.
✓ Branch 216 taken 21848 times.
✓ Branch 217 taken 31 times.
✗ Branch 218 not taken.
✓ Branch 219 taken 41791 times.
✓ Branch 220 taken 92 times.
✓ Branch 221 taken 49959 times.
✗ Branch 222 not taken.
✗ Branch 223 not taken.
✓ Branch 224 taken 37 times.
✗ Branch 225 not taken.
✗ Branch 226 not taken.
✓ Branch 227 taken 109 times.
✗ Branch 228 not taken.
✗ Branch 229 not taken.
✗ Branch 230 not taken.
✗ Branch 231 not taken.
✗ Branch 232 not taken.
✓ Branch 233 taken 40 times.
✗ Branch 234 not taken.
✗ Branch 235 not taken.
✗ Branch 236 not taken.
✗ Branch 237 not taken.
✗ Branch 238 not taken.
✗ Branch 239 not taken.
✗ Branch 240 not taken.
✗ Branch 241 not taken.
✗ Branch 242 not taken.
✗ Branch 243 not taken.
✗ Branch 244 not taken.
✗ Branch 245 not taken.
✓ Branch 246 taken 6 times.
✗ Branch 247 not taken.
✗ Branch 248 not taken.
✗ Branch 249 not taken.
✗ Branch 250 not taken.
✗ Branch 251 not taken.
✗ Branch 252 not taken.
✗ Branch 253 not taken.
✗ Branch 254 not taken.
✓ Branch 255 taken 3013 times.
✗ Branch 256 not taken.
✗ Branch 257 not taken.
✗ Branch 258 not taken.
✗ Branch 259 not taken.
✗ Branch 260 not taken.
✓ Branch 261 taken 68 times.
✗ Branch 262 not taken.
✗ Branch 263 not taken.
✗ Branch 264 not taken.
✗ Branch 265 not taken.
✗ Branch 266 not taken.
✗ Branch 267 not taken.
✗ Branch 268 not taken.
✗ Branch 269 not taken.
✗ Branch 270 not taken.
✗ Branch 271 not taken.
✗ Branch 272 not taken.
✗ Branch 273 not taken.
✗ Branch 274 not taken.
✗ Branch 275 not taken.
✗ Branch 276 not taken.
✗ Branch 277 not taken.
✗ Branch 278 not taken.
✗ Branch 279 not taken.
✗ Branch 280 not taken.
✗ Branch 281 not taken.
✗ Branch 282 not taken.
✗ Branch 283 not taken.
✗ Branch 284 not taken.
✗ Branch 285 not taken.
✗ Branch 286 not taken.
✗ Branch 287 not taken.
✗ Branch 288 not taken.
✗ Branch 289 not taken.
✗ Branch 290 not taken.
✗ Branch 291 not taken.
✗ Branch 292 not taken.
✗ Branch 293 not taken.
✗ Branch 294 not taken.
✗ Branch 295 not taken.
✗ Branch 296 not taken.
✗ Branch 297 not taken.
✗ Branch 298 not taken.
✗ Branch 299 not taken.
✗ Branch 300 not taken.
✗ Branch 301 not taken.
✗ Branch 302 not taken.
✗ Branch 303 not taken.
✗ Branch 304 not taken.
✗ Branch 305 not taken.
✗ Branch 306 not taken.
✗ Branch 307 not taken.
✗ Branch 308 not taken.
✗ Branch 309 not taken.
✗ Branch 310 not taken.
✗ Branch 311 not taken.
✗ Branch 312 not taken.
✗ Branch 313 not taken.
✗ Branch 314 not taken.
✗ Branch 315 not taken.
✗ Branch 316 not taken.
✗ Branch 317 not taken.
✗ Branch 318 not taken.
✗ Branch 319 not taken.
✗ Branch 320 not taken.
✗ Branch 321 not taken.
✗ Branch 322 not taken.
✗ Branch 323 not taken.
✗ Branch 324 not taken.
✗ Branch 325 not taken.
✗ Branch 326 not taken.
✗ Branch 327 not taken.
✗ Branch 328 not taken.
✗ Branch 329 not taken.
✗ Branch 330 not taken.
✗ Branch 331 not taken.
✗ Branch 332 not taken.
✗ Branch 333 not taken.
✗ Branch 334 not taken.
✓ Branch 335 taken 2760 times.
✗ Branch 336 not taken.
✗ Branch 337 not taken.
✗ Branch 338 not taken.
✗ Branch 339 not taken.
✗ Branch 340 not taken.
✗ Branch 341 not taken.
✗ Branch 342 not taken.
✓ Branch 343 taken 70 times.
✗ Branch 344 not taken.
✗ Branch 345 not taken.
✗ Branch 346 not taken.
✗ Branch 347 not taken.
✗ Branch 348 not taken.
✗ Branch 349 not taken.
✗ Branch 350 not taken.
✓ Branch 351 taken 193740 times.
✗ Branch 352 not taken.
✓ Branch 353 taken 180 times.
✗ Branch 354 not taken.
✓ Branch 355 taken 65038 times.
✗ Branch 356 not taken.
✗ Branch 357 not taken.
✓ Branch 358 taken 8276 times.
✗ Branch 359 not taken.
✗ Branch 360 not taken.
✗ Branch 361 not taken.
✓ Branch 362 taken 1175 times.
✗ Branch 363 not taken.
✗ Branch 364 not taken.
✓ Branch 365 taken 49 times.
✓ Branch 366 taken 69347 times.
✓ Branch 367 taken 139174 times.
✗ Branch 368 not taken.
✓ Branch 369 taken 1853 times.
✗ Branch 370 not taken.
✗ Branch 371 not taken.
✓ Branch 372 taken 2049 times.
✗ Branch 373 not taken.
✓ Branch 374 taken 404 times.
✗ Branch 375 not taken.
✓ Branch 376 taken 457 times.
✗ Branch 377 not taken.
✓ Branch 378 taken 683 times.
✓ Branch 379 taken 4922 times.
✓ Branch 380 taken 16 times.
✓ Branch 381 taken 1841 times.
✗ Branch 382 not taken.
✓ Branch 383 taken 60616 times.
✓ Branch 384 taken 60616 times.
✓ Branch 385 taken 156 times.
✓ Branch 386 taken 63470 times.
✗ Branch 387 not taken.
✗ Branch 388 not taken.
✗ Branch 389 not taken.
✗ Branch 390 not taken.
✓ Branch 391 taken 61740 times.
✓ Branch 392 taken 61757 times.
✗ Branch 393 not taken.
✓ Branch 394 taken 10 times.
✓ Branch 395 taken 10 times.
✓ Branch 396 taken 497624 times.
✓ Branch 397 taken 16104 times.
✗ Branch 398 not taken.
✗ Branch 399 not taken.
✗ Branch 400 not taken.
✓ Branch 401 taken 60886 times.
✓ Branch 402 taken 603 times.
✗ Branch 403 not taken.
✓ Branch 404 taken 206 times.
✗ Branch 405 not taken.
✗ Branch 406 not taken.
✗ Branch 407 not taken.
✗ Branch 408 not taken.
✗ Branch 409 not taken.
✓ Branch 410 taken 265 times.
✗ Branch 411 not taken.
✗ Branch 412 not taken.
✗ Branch 413 not taken.
✗ Branch 414 not taken.
✗ Branch 415 not taken.
✗ Branch 416 not taken.
✗ Branch 417 not taken.
✗ Branch 418 not taken.
✗ Branch 419 not taken.
✗ Branch 420 not taken.
✗ Branch 421 not taken.
✗ Branch 422 not taken.
✓ Branch 423 taken 226569 times.
✗ Branch 424 not taken.
✓ Branch 425 taken 226856 times.
✓ Branch 426 taken 6823 times.
✓ Branch 427 taken 6048 times.
✗ Branch 428 not taken.
✓ Branch 429 taken 138270 times.
✗ Branch 430 not taken.
✗ Branch 431 not taken.
✓ Branch 432 taken 264908 times.
✓ Branch 433 taken 134925 times.
✗ Branch 434 not taken.
✗ Branch 435 not taken.
✗ Branch 436 not taken.
✓ Branch 437 taken 131702 times.
✗ Branch 438 not taken.
✓ Branch 439 taken 47 times.
✓ Branch 440 taken 12175 times.
✓ Branch 441 taken 132679 times.
✓ Branch 442 taken 23997 times.
✗ Branch 443 not taken.
✓ Branch 444 taken 9747 times.
✗ Branch 445 not taken.
✗ Branch 446 not taken.
✓ Branch 447 taken 2072 times.
✗ Branch 448 not taken.
✓ Branch 449 taken 41 times.
✗ Branch 450 not taken.
✓ Branch 451 taken 41 times.
✓ Branch 452 taken 549 times.
✓ Branch 453 taken 49622 times.
✓ Branch 454 taken 1104 times.
✓ Branch 455 taken 111461 times.
✗ Branch 456 not taken.
✓ Branch 457 taken 138269 times.
✓ Branch 458 taken 137776 times.
✓ Branch 459 taken 35370 times.
✓ Branch 460 taken 38448 times.
✗ Branch 461 not taken.
✗ Branch 462 not taken.
✗ Branch 463 not taken.
✓ Branch 464 taken 44 times.
✓ Branch 465 taken 111461 times.
✓ Branch 466 taken 111461 times.
✓ Branch 467 taken 20016 times.
✗ Branch 468 not taken.
✗ Branch 469 not taken.
✗ Branch 470 not taken.
✓ Branch 471 taken 1275 times.
✓ Branch 472 taken 4214 times.
✗ Branch 473 not taken.
✗ Branch 474 not taken.
✗ Branch 475 not taken.
✗ Branch 476 not taken.
✗ Branch 477 not taken.
✗ Branch 478 not taken.
✗ Branch 479 not taken.
✗ Branch 480 not taken.
✗ Branch 481 not taken.
✗ Branch 482 not taken.
✗ Branch 483 not taken.
✗ Branch 484 not taken.
✗ Branch 485 not taken.
✗ Branch 486 not taken.
✗ Branch 487 not taken.
✗ Branch 488 not taken.
✗ Branch 489 not taken.
✗ Branch 490 not taken.
✗ Branch 491 not taken.
✗ Branch 492 not taken.
✗ Branch 493 not taken.
✓ Branch 494 taken 1037003 times.
✗ Branch 495 not taken.
✓ Branch 496 taken 3 times.
✗ Branch 497 not taken.
✗ Branch 498 not taken.
✗ Branch 499 not taken.
✓ Branch 500 taken 1041414 times.
✓ Branch 501 taken 969235 times.
✓ Branch 502 taken 972500 times.
✗ Branch 503 not taken.
✓ Branch 504 taken 71 times.
✓ Branch 505 taken 28037 times.
✗ Branch 506 not taken.
✗ Branch 507 not taken.
✗ Branch 508 not taken.
✗ Branch 509 not taken.
✗ Branch 510 not taken.
✗ Branch 511 not taken.
✓ Branch 512 taken 1045600 times.
✗ Branch 513 not taken.
✗ Branch 514 not taken.
✗ Branch 515 not taken.
✗ Branch 516 not taken.
✗ Branch 517 not taken.
✗ Branch 518 not taken.
✗ Branch 519 not taken.
✗ Branch 520 not taken.
✗ Branch 521 not taken.
✓ Branch 522 taken 3 times.
✗ Branch 523 not taken.
✓ Branch 524 taken 4414 times.
✓ Branch 525 taken 1032892 times.
✗ Branch 526 not taken.
✓ Branch 527 taken 788 times.
✗ Branch 528 not taken.
✓ Branch 529 taken 321 times.
✓ Branch 530 taken 94 times.
✗ Branch 531 not taken.
✓ Branch 532 taken 13 times.
✓ Branch 533 taken 77610 times.
✓ Branch 534 taken 1181 times.
✓ Branch 535 taken 4183 times.
✓ Branch 536 taken 7067 times.
✓ Branch 537 taken 7067 times.
✓ Branch 538 taken 2 times.
✓ Branch 539 taken 28758 times.
✗ Branch 540 not taken.
✓ Branch 541 taken 1094 times.
✗ Branch 542 not taken.
✗ Branch 543 not taken.
✓ Branch 544 taken 1019271 times.
✓ Branch 545 taken 10538 times.
✓ Branch 546 taken 10538 times.
✓ Branch 547 taken 8695 times.
✓ Branch 548 taken 4911 times.
✗ Branch 549 not taken.
✗ Branch 550 not taken.
✗ Branch 551 not taken.
✓ Branch 552 taken 545362 times.
✗ Branch 553 not taken.
✗ Branch 554 not taken.
✗ Branch 555 not taken.
✗ Branch 556 not taken.
✗ Branch 557 not taken.
✗ Branch 558 not taken.
✗ Branch 559 not taken.
✗ Branch 560 not taken.
✗ Branch 561 not taken.
✗ Branch 562 not taken.
✗ Branch 563 not taken.
✗ Branch 564 not taken.
✗ Branch 565 not taken.
✗ Branch 566 not taken.
✗ Branch 567 not taken.
✗ Branch 568 not taken.
✗ Branch 569 not taken.
✗ Branch 570 not taken.
✗ Branch 571 not taken.
✗ Branch 572 not taken.
✗ Branch 573 not taken.
✗ Branch 574 not taken.
✗ Branch 575 not taken.
✗ Branch 576 not taken.
✗ Branch 577 not taken.
✗ Branch 578 not taken.
✗ Branch 579 not taken.
✗ Branch 580 not taken.
✗ Branch 581 not taken.
✓ Branch 582 taken 26 times.
✓ Branch 583 taken 88964 times.
✓ Branch 584 taken 88970 times.
✓ Branch 585 taken 88970 times.
✓ Branch 586 taken 2705905 times.
✓ Branch 587 taken 8 times.
✗ Branch 588 not taken.
✗ Branch 589 not taken.
✗ Branch 590 not taken.
✓ Branch 591 taken 64 times.
✗ Branch 592 not taken.
✗ Branch 593 not taken.
✗ Branch 594 not taken.
✗ Branch 595 not taken.
✗ Branch 596 not taken.
✗ Branch 597 not taken.
✗ Branch 598 not taken.
✗ Branch 599 not taken.
✗ Branch 600 not taken.
✗ Branch 601 not taken.
✓ Branch 602 taken 3 times.
✗ Branch 603 not taken.
✓ Branch 604 taken 394 times.
✗ Branch 605 not taken.
✗ Branch 606 not taken.
✗ Branch 607 not taken.
✓ Branch 608 taken 649 times.
✗ Branch 609 not taken.
✗ Branch 610 not taken.
✗ Branch 611 not taken.
✗ Branch 612 not taken.
✗ Branch 613 not taken.
✗ Branch 614 not taken.
✗ Branch 615 not taken.
✗ Branch 616 not taken.
✗ Branch 617 not taken.
✗ Branch 618 not taken.
✗ Branch 619 not taken.
✗ Branch 620 not taken.
✗ Branch 621 not taken.
✗ Branch 622 not taken.
✗ Branch 623 not taken.
✗ Branch 624 not taken.
✗ Branch 625 not taken.
✓ Branch 626 taken 377 times.
✗ Branch 627 not taken.
✓ Branch 628 taken 120341 times.
✓ Branch 629 taken 6481 times.
✗ Branch 630 not taken.
✓ Branch 631 taken 3560 times.
✗ Branch 632 not taken.
✓ Branch 633 taken 81346 times.
✗ Branch 634 not taken.
✓ Branch 635 taken 5356632 times.
✓ Branch 636 taken 5344380 times.
✓ Branch 637 taken 32221 times.
✓ Branch 638 taken 760 times.
✗ Branch 639 not taken.
✗ Branch 640 not taken.
✗ Branch 641 not taken.
✗ Branch 642 not taken.
✗ Branch 643 not taken.
✗ Branch 644 not taken.
✗ Branch 645 not taken.
✗ Branch 646 not taken.
✗ Branch 647 not taken.
✗ Branch 648 not taken.
✗ Branch 649 not taken.
✗ Branch 650 not taken.
✗ Branch 651 not taken.
✗ Branch 652 not taken.
✗ Branch 653 not taken.
✗ Branch 654 not taken.
✗ Branch 655 not taken.
✗ Branch 656 not taken.
✗ Branch 657 not taken.
✗ Branch 658 not taken.
✗ Branch 659 not taken.
✗ Branch 660 not taken.
✗ Branch 661 not taken.
✗ Branch 662 not taken.
✗ Branch 663 not taken.
✗ Branch 664 not taken.
✗ Branch 665 not taken.
✗ Branch 666 not taken.
✗ Branch 667 not taken.
✗ Branch 668 not taken.
✗ Branch 669 not taken.
✗ Branch 670 not taken.
✗ Branch 671 not taken.
✗ Branch 672 not taken.
✗ Branch 673 not taken.
✗ Branch 674 not taken.
✗ Branch 675 not taken.
✗ Branch 676 not taken.
✗ Branch 677 not taken.
✗ Branch 678 not taken.
✗ Branch 679 not taken.
✗ Branch 680 not taken.
✗ Branch 681 not taken.
✗ Branch 682 not taken.
✗ Branch 683 not taken.
✓ Branch 684 taken 128 times.
✓ Branch 685 taken 128 times.
✓ Branch 686 taken 128 times.
✗ Branch 687 not taken.
✗ Branch 688 not taken.
✗ Branch 689 not taken.
✓ Branch 690 taken 5 times.
✓ Branch 691 taken 5 times.
✗ Branch 692 not taken.
✗ Branch 693 not taken.
✗ Branch 694 not taken.
✗ Branch 695 not taken.
✗ Branch 696 not taken.
✗ Branch 697 not taken.
✗ Branch 698 not taken.
✗ Branch 699 not taken.
✗ Branch 700 not taken.
✗ Branch 701 not taken.
✗ Branch 702 not taken.
✗ Branch 703 not taken.
✗ Branch 704 not taken.
✗ Branch 705 not taken.
✗ Branch 706 not taken.
✗ Branch 707 not taken.
✗ Branch 708 not taken.
✗ Branch 709 not taken.
✗ Branch 710 not taken.
✗ Branch 711 not taken.
✗ Branch 712 not taken.
✗ Branch 713 not taken.
✗ Branch 714 not taken.
✗ Branch 715 not taken.
✗ Branch 716 not taken.
✗ Branch 717 not taken.
✗ Branch 718 not taken.
✗ Branch 719 not taken.
✗ Branch 720 not taken.
✗ Branch 721 not taken.
✗ Branch 722 not taken.
✗ Branch 723 not taken.
✗ Branch 724 not taken.
✗ Branch 725 not taken.
✗ Branch 726 not taken.
✗ Branch 727 not taken.
✗ Branch 728 not taken.
✓ Branch 729 taken 14277 times.
✗ Branch 730 not taken.
✓ Branch 731 taken 27297 times.
✓ Branch 732 taken 531 times.
✗ Branch 733 not taken.
✗ Branch 734 not taken.
✗ Branch 735 not taken.
✓ Branch 736 taken 4 times.
✓ Branch 737 taken 900 times.
✓ Branch 738 taken 7214 times.
✓ Branch 739 taken 3579 times.
✗ Branch 740 not taken.
✓ Branch 741 taken 11 times.
✗ Branch 742 not taken.
✗ Branch 743 not taken.
✗ Branch 744 not taken.
✗ Branch 745 not taken.
✗ Branch 746 not taken.
✗ Branch 747 not taken.
✗ Branch 748 not taken.
✗ Branch 749 not taken.
✗ Branch 750 not taken.
✗ Branch 751 not taken.
✗ Branch 752 not taken.
✗ Branch 753 not taken.
✗ Branch 754 not taken.
✗ Branch 755 not taken.
✗ Branch 756 not taken.
✗ Branch 757 not taken.
✗ Branch 758 not taken.
✗ Branch 759 not taken.
✗ Branch 760 not taken.
✗ Branch 761 not taken.
✗ Branch 762 not taken.
✗ Branch 763 not taken.
✗ Branch 764 not taken.
✗ Branch 765 not taken.
✗ Branch 766 not taken.
✗ Branch 767 not taken.
✗ Branch 768 not taken.
✗ Branch 769 not taken.
✗ Branch 770 not taken.
✗ Branch 771 not taken.
✗ Branch 772 not taken.
✗ Branch 773 not taken.
✗ Branch 774 not taken.
✗ Branch 775 not taken.
✗ Branch 776 not taken.
✗ Branch 777 not taken.
✗ Branch 778 not taken.
✗ Branch 779 not taken.
✗ Branch 780 not taken.
✗ Branch 781 not taken.
✗ Branch 782 not taken.
✗ Branch 783 not taken.
✗ Branch 784 not taken.
✗ Branch 785 not taken.
✗ Branch 786 not taken.
✗ Branch 787 not taken.
✗ Branch 788 not taken.
✗ Branch 789 not taken.
✗ Branch 790 not taken.
✗ Branch 791 not taken.
✗ Branch 792 not taken.
✗ Branch 793 not taken.
✗ Branch 794 not taken.
✗ Branch 795 not taken.
✗ Branch 796 not taken.
✗ Branch 797 not taken.
✗ Branch 798 not taken.
✗ Branch 799 not taken.
✗ Branch 800 not taken.
✗ Branch 801 not taken.
✗ Branch 802 not taken.
✗ Branch 803 not taken.
✗ Branch 804 not taken.
✗ Branch 805 not taken.
✗ Branch 806 not taken.
✗ Branch 807 not taken.
✗ Branch 808 not taken.
✗ Branch 809 not taken.
✗ Branch 810 not taken.
✗ Branch 811 not taken.
✗ Branch 812 not taken.
✗ Branch 813 not taken.
✗ Branch 814 not taken.
✗ Branch 815 not taken.
✗ Branch 816 not taken.
✗ Branch 817 not taken.
✗ Branch 818 not taken.
✗ Branch 819 not taken.
✗ Branch 820 not taken.
✗ Branch 821 not taken.
✗ Branch 822 not taken.
✗ Branch 823 not taken.
✗ Branch 824 not taken.
✗ Branch 825 not taken.
✗ Branch 826 not taken.
✗ Branch 827 not taken.
✗ Branch 828 not taken.
✗ Branch 829 not taken.
✗ Branch 830 not taken.
✗ Branch 831 not taken.
✗ Branch 832 not taken.
✗ Branch 833 not taken.
✗ Branch 834 not taken.
✗ Branch 835 not taken.
✗ Branch 836 not taken.
✗ Branch 837 not taken.
✗ Branch 838 not taken.
✗ Branch 839 not taken.
✗ Branch 840 not taken.
✗ Branch 841 not taken.
✗ Branch 842 not taken.
✗ Branch 843 not taken.
✗ Branch 844 not taken.
✗ Branch 845 not taken.
✗ Branch 846 not taken.
✗ Branch 847 not taken.
✗ Branch 848 not taken.
✗ Branch 849 not taken.
✗ Branch 850 not taken.
✗ Branch 851 not taken.
✗ Branch 852 not taken.
✗ Branch 853 not taken.
✗ Branch 854 not taken.
✗ Branch 855 not taken.
✓ Branch 856 taken 80782 times.
✓ Branch 857 taken 2497 times.
✓ Branch 858 taken 56174 times.
✗ Branch 859 not taken.
✗ Branch 860 not taken.
✗ Branch 861 not taken.
✗ Branch 862 not taken.
✗ Branch 863 not taken.
✗ Branch 864 not taken.
✗ Branch 865 not taken.
✗ Branch 866 not taken.
✗ Branch 867 not taken.
✗ Branch 868 not taken.
✗ Branch 869 not taken.
✗ Branch 870 not taken.
✗ Branch 871 not taken.
✗ Branch 872 not taken.
✗ Branch 873 not taken.
✗ Branch 874 not taken.
✗ Branch 875 not taken.
✗ Branch 876 not taken.
✗ Branch 877 not taken.
✗ Branch 878 not taken.
✗ Branch 879 not taken.
✗ Branch 880 not taken.
✗ Branch 881 not taken.
✗ Branch 882 not taken.
✗ Branch 883 not taken.
✗ Branch 884 not taken.
✗ Branch 885 not taken.
✗ Branch 886 not taken.
✗ Branch 887 not taken.
✗ Branch 888 not taken.
✗ Branch 889 not taken.
✗ Branch 890 not taken.
✗ Branch 891 not taken.
✗ Branch 892 not taken.
✗ Branch 893 not taken.
✗ Branch 894 not taken.
✗ Branch 895 not taken.
✗ Branch 896 not taken.
✗ Branch 897 not taken.
✗ Branch 898 not taken.
✗ Branch 899 not taken.
✗ Branch 900 not taken.
✓ Branch 901 taken 3225 times.
✗ Branch 902 not taken.
✗ Branch 903 not taken.
✗ Branch 904 not taken.
✗ Branch 905 not taken.
✗ Branch 906 not taken.
✗ Branch 907 not taken.
✗ Branch 908 not taken.
✗ Branch 909 not taken.
✗ Branch 910 not taken.
✗ Branch 911 not taken.
✗ Branch 912 not taken.
✗ Branch 913 not taken.
✗ Branch 914 not taken.
✗ Branch 915 not taken.
✗ Branch 916 not taken.
✗ Branch 917 not taken.
✗ Branch 918 not taken.
✗ Branch 919 not taken.
✗ Branch 920 not taken.
✗ Branch 921 not taken.
✗ Branch 922 not taken.
✗ Branch 923 not taken.
✗ Branch 924 not taken.
✗ Branch 925 not taken.
✗ Branch 926 not taken.
✗ Branch 927 not taken.
✗ Branch 928 not taken.
✗ Branch 929 not taken.
✗ Branch 930 not taken.
✗ Branch 931 not taken.
✗ Branch 932 not taken.
✗ Branch 933 not taken.
✗ Branch 934 not taken.
✗ Branch 935 not taken.
✗ Branch 936 not taken.
✗ Branch 937 not taken.
✗ Branch 938 not taken.
✗ Branch 939 not taken.
✗ Branch 940 not taken.
✗ Branch 941 not taken.
✗ Branch 942 not taken.
✗ Branch 943 not taken.
✗ Branch 944 not taken.
✗ Branch 945 not taken.
✗ Branch 946 not taken.
✗ Branch 947 not taken.
✗ Branch 948 not taken.
✗ Branch 949 not taken.
✗ Branch 950 not taken.
✗ Branch 951 not taken.
✗ Branch 952 not taken.
✗ Branch 953 not taken.
✗ Branch 954 not taken.
✗ Branch 955 not taken.
✗ Branch 956 not taken.
✗ Branch 957 not taken.
✗ Branch 958 not taken.
✗ Branch 959 not taken.
✗ Branch 960 not taken.
✗ Branch 961 not taken.
✗ Branch 962 not taken.
✗ Branch 963 not taken.
✗ Branch 964 not taken.
✗ Branch 965 not taken.
✗ Branch 966 not taken.
✗ Branch 967 not taken.
✗ Branch 968 not taken.
✗ Branch 969 not taken.
✗ Branch 970 not taken.
✗ Branch 971 not taken.
✗ Branch 972 not taken.
✗ Branch 973 not taken.
✗ Branch 974 not taken.
✗ Branch 975 not taken.
✗ Branch 976 not taken.
✗ Branch 977 not taken.
✗ Branch 978 not taken.
✗ Branch 979 not taken.
✗ Branch 980 not taken.
✗ Branch 981 not taken.
✗ Branch 982 not taken.
✗ Branch 983 not taken.
✗ Branch 984 not taken.
✗ Branch 985 not taken.
✗ Branch 986 not taken.
✗ Branch 987 not taken.
✗ Branch 988 not taken.
✗ Branch 989 not taken.
✗ Branch 990 not taken.
✗ Branch 991 not taken.
✗ Branch 992 not taken.
✗ Branch 993 not taken.
✗ Branch 994 not taken.
✗ Branch 995 not taken.
✗ Branch 996 not taken.
✗ Branch 997 not taken.
✗ Branch 998 not taken.
✗ Branch 999 not taken.
✗ Branch 1000 not taken.
✗ Branch 1001 not taken.
✗ Branch 1002 not taken.
✗ Branch 1003 not taken.
✗ Branch 1004 not taken.
✗ Branch 1005 not taken.
✗ Branch 1006 not taken.
✗ Branch 1007 not taken.
✗ Branch 1008 not taken.
✗ Branch 1009 not taken.
✗ Branch 1010 not taken.
✗ Branch 1011 not taken.
✗ Branch 1012 not taken.
✗ Branch 1013 not taken.
✗ Branch 1014 not taken.
✗ Branch 1015 not taken.
✗ Branch 1016 not taken.
✗ Branch 1017 not taken.
✗ Branch 1018 not taken.
✗ Branch 1019 not taken.
✗ Branch 1020 not taken.
✗ Branch 1021 not taken.
✗ Branch 1022 not taken.
✗ Branch 1023 not taken.
✗ Branch 1024 not taken.
✗ Branch 1025 not taken.
✗ Branch 1026 not taken.
✗ Branch 1027 not taken.
✗ Branch 1028 not taken.
✗ Branch 1029 not taken.
✗ Branch 1030 not taken.
✗ Branch 1031 not taken.
✗ Branch 1032 not taken.
✗ Branch 1033 not taken.
✗ Branch 1034 not taken.
✗ Branch 1035 not taken.
✗ Branch 1036 not taken.
✗ Branch 1037 not taken.
✗ Branch 1038 not taken.
✗ Branch 1039 not taken.
✗ Branch 1040 not taken.
✗ Branch 1041 not taken.
✗ Branch 1042 not taken.
✗ Branch 1043 not taken.
✗ Branch 1044 not taken.
✗ Branch 1045 not taken.
✗ Branch 1046 not taken.
✗ Branch 1047 not taken.
✗ Branch 1048 not taken.
✗ Branch 1049 not taken.
✗ Branch 1050 not taken.
✗ Branch 1051 not taken.
✗ Branch 1052 not taken.
✗ Branch 1053 not taken.
✗ Branch 1054 not taken.
✗ Branch 1055 not taken.
✗ Branch 1056 not taken.
✗ Branch 1057 not taken.
✗ Branch 1058 not taken.
✗ Branch 1059 not taken.
✗ Branch 1060 not taken.
✗ Branch 1061 not taken.
✗ Branch 1062 not taken.
✗ Branch 1063 not taken.
✗ Branch 1064 not taken.
✗ Branch 1065 not taken.
✗ Branch 1066 not taken.
✗ Branch 1067 not taken.
✗ Branch 1068 not taken.
✗ Branch 1069 not taken.
✗ Branch 1070 not taken.
✗ Branch 1071 not taken.
✗ Branch 1072 not taken.
✗ Branch 1073 not taken.
✗ Branch 1074 not taken.
✗ Branch 1075 not taken.
✗ Branch 1076 not taken.
✗ Branch 1077 not taken.
✗ Branch 1078 not taken.
✗ Branch 1079 not taken.
✗ Branch 1080 not taken.
✗ Branch 1081 not taken.
✗ Branch 1082 not taken.
✗ Branch 1083 not taken.
✗ Branch 1084 not taken.
✗ Branch 1085 not taken.
✗ Branch 1086 not taken.
✗ Branch 1087 not taken.
✗ Branch 1088 not taken.
✗ Branch 1089 not taken.
✗ Branch 1090 not taken.
✗ Branch 1091 not taken.
✗ Branch 1092 not taken.
✗ Branch 1093 not taken.
✗ Branch 1094 not taken.
✗ Branch 1095 not taken.
✗ Branch 1096 not taken.
✗ Branch 1097 not taken.
✗ Branch 1098 not taken.
✗ Branch 1099 not taken.
✗ Branch 1100 not taken.
✗ Branch 1101 not taken.
✗ Branch 1102 not taken.
✗ Branch 1103 not taken.
✗ Branch 1104 not taken.
✗ Branch 1105 not taken.
✗ Branch 1106 not taken.
✗ Branch 1107 not taken.
✗ Branch 1108 not taken.
✗ Branch 1109 not taken.
✗ Branch 1110 not taken.
✗ Branch 1111 not taken.
✗ Branch 1112 not taken.
✗ Branch 1113 not taken.
✗ Branch 1114 not taken.
✗ Branch 1115 not taken.
✗ Branch 1116 not taken.
✗ Branch 1117 not taken.
✗ Branch 1118 not taken.
✗ Branch 1119 not taken.
✗ Branch 1120 not taken.
✗ Branch 1121 not taken.
✗ Branch 1122 not taken.
✗ Branch 1123 not taken.
✗ Branch 1124 not taken.
✗ Branch 1125 not taken.
✓ Branch 1126 taken 503793134 times.
✓ Branch 1127 taken 409929 times.
✓ Branch 1128 taken 375716 times.
✓ Branch 1129 taken 10112990 times.
✓ Branch 1130 taken 23554631 times.
✓ Branch 1131 taken 78110851 times.
✓ Branch 1132 taken 18513311 times.
✗ Branch 1133 not taken.
✓ Branch 1134 taken 116558 times.
✗ Branch 1135 not taken.
✓ Branch 1136 taken 257126 times.
✗ Branch 1137 not taken.
✓ Branch 1138 taken 758256 times.
✗ Branch 1139 not taken.
✗ Branch 1140 not taken.
✗ Branch 1141 not taken.
✗ Branch 1142 not taken.
✗ Branch 1143 not taken.
✗ Branch 1144 not taken.
✓ Branch 1145 taken 142 times.
✗ Branch 1146 not taken.
✗ Branch 1147 not taken.
✗ Branch 1148 not taken.
✗ Branch 1149 not taken.
✗ Branch 1150 not taken.
✗ Branch 1151 not taken.
✗ Branch 1152 not taken.
✗ Branch 1153 not taken.
✗ Branch 1154 not taken.
✗ Branch 1155 not taken.
✓ Branch 1156 taken 284 times.
✗ Branch 1157 not taken.
✗ Branch 1158 not taken.
✗ Branch 1159 not taken.
✓ Branch 1160 taken 303330 times.
✗ Branch 1161 not taken.
✗ Branch 1162 not taken.
✗ Branch 1163 not taken.
✗ Branch 1164 not taken.
✗ Branch 1165 not taken.
✗ Branch 1166 not taken.
✗ Branch 1167 not taken.
✓ Branch 1168 taken 58 times.
✗ Branch 1169 not taken.
✗ Branch 1170 not taken.
✓ Branch 1171 taken 74 times.
✗ Branch 1172 not taken.
✗ Branch 1173 not taken.
✗ Branch 1174 not taken.
✗ Branch 1175 not taken.
✗ Branch 1176 not taken.
✗ Branch 1177 not taken.
✗ Branch 1178 not taken.
✗ Branch 1179 not taken.
✗ Branch 1180 not taken.
✗ Branch 1181 not taken.
✗ Branch 1182 not taken.
✗ Branch 1183 not taken.
✗ Branch 1184 not taken.
✗ Branch 1185 not taken.
✗ Branch 1186 not taken.
✗ Branch 1187 not taken.
✗ Branch 1188 not taken.
✗ Branch 1189 not taken.
✗ Branch 1190 not taken.
✗ Branch 1191 not taken.
✗ Branch 1192 not taken.
✗ Branch 1193 not taken.
1398816198 switch(arg)
13478 {
13479 //debug ri->d[]
13480 case DEBUGD:
13481 {
13482 int32_t a = vbound((ri->d[rINDEX] / 10000), 0, 255);
13483 ri->d[a] = value/10000;
13484 break;
13485 }
13486
13487 ///----------------------------------------------------------------------------------------------------//
13488 //FFC Variables
13489 case DATA:
13490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2270014 times.
2270014 if(BC::checkFFC(ri->ffcref, "ffc->Data") == SH::_NoError)
13491 {
13492 2270014 tmpscr->ffcs[ri->ffcref].setData(vbound(value/10000,0,MAXCOMBOS-1));
13493 2270014 }
13494 2270014 break;
13495
13496 case FFSCRIPT:
13497
1/2
✓ Branch 0 taken 9724 times.
✗ Branch 1 not taken.
9724 if(BC::checkFFC(ri->ffcref, "ffc->Script") == SH::_NoError)
13498 {
13499 9724 tmpscr->ffcs[ri->ffcref].script = vbound(value/10000, 0, NUMSCRIPTFFC-1);
13500
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9724 times.
9724 if ( get_qr(qr_CLEARINITDONSCRIPTCHANGE))
13501 {
13502
2/2
✓ Branch 0 taken 19448 times.
✓ Branch 1 taken 9724 times.
29172 for(int32_t i=0; i<2; i++)
13503 19448 tmpscr->ffcs[ri->ffcref].inita[i] = 0;
13504
13505
2/2
✓ Branch 0 taken 77792 times.
✓ Branch 1 taken 9724 times.
87516 for(int32_t i=0; i<8; i++)
13506 77792 tmpscr->ffcs[ri->ffcref].initd[i] = 0;
13507 9724 }
13508
2/2
✓ Branch 0 taken 155584 times.
✓ Branch 1 taken 9724 times.
165308 for(int32_t i=0; i<16; i++)
13509 155584 ffmisc[ri->ffcref][i] = 0;
13510
13511 9724 auto& data = get_script_engine_data(ScriptType::FFC, ri->ffcref);
13512 9724 data.ref.Clear();
13513 9724 data.initialized = false;
13514 9724 FFScript::deallocateAllArrays(ScriptType::FFC, ri->ffcref);
13515 9724 }
13516 9724 break;
13517
13518
13519 case FCSET:
13520
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1041229 times.
1041229 if(BC::checkFFC(ri->ffcref, "ffc->CSet") == SH::_NoError)
13521 1041229 tmpscr->ffcs[ri->ffcref].cset = (value/10000)&15;
13522 1041229 break;
13523
13524 case DELAY:
13525
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2881 times.
2881 if(BC::checkFFC(ri->ffcref, "ffc->Delay") == SH::_NoError)
13526 2881 tmpscr->ffcs[ri->ffcref].delay = value/10000;
13527 2881 break;
13528
13529 case FX:
13530
1/2
✓ Branch 0 taken 1213780 times.
✗ Branch 1 not taken.
1213780 if(BC::checkFFC(ri->ffcref, "ffc->X") == SH::_NoError)
13531 1213780 tmpscr->ffcs[ri->ffcref].x = zslongToFix(value);
13532 1213780 break;
13533
13534 case FY:
13535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1215785 times.
1215785 if(BC::checkFFC(ri->ffcref, "ffc->Y") == SH::_NoError)
13536 1215785 tmpscr->ffcs[ri->ffcref].y=zslongToFix(value);
13537 1215785 break;
13538
13539 case XD:
13540
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9444 times.
9444 if(BC::checkFFC(ri->ffcref, "ffc->Vx") == SH::_NoError)
13541 9444 tmpscr->ffcs[ri->ffcref].vx=zslongToFix(value);
13542 9444 break;
13543
13544 case YD:
13545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9428 times.
9428 if(BC::checkFFC(ri->ffcref, "ffc->Vy") == SH::_NoError)
13546 9428 tmpscr->ffcs[ri->ffcref].vy=zslongToFix(value);
13547 9428 break;
13548
13549 case FFCID:
13550 break;
13551
13552 case XD2:
13553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9172 times.
9172 if(BC::checkFFC(ri->ffcref, "ffc->Ax") == SH::_NoError)
13554 9172 tmpscr->ffcs[ri->ffcref].ax=zslongToFix(value);
13555 9172 break;
13556
13557 case YD2:
13558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9172 times.
9172 if(BC::checkFFC(ri->ffcref, "ffc->Ay") == SH::_NoError)
13559 9172 tmpscr->ffcs[ri->ffcref].ay=zslongToFix(value);
13560 9172 break;
13561
13562 case FFFLAGSD:
13563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 229038 times.
229038 if(BC::checkFFC(ri->ffcref, "ffc->Flags[]") == SH::_NoError)
13564 {
13565 229038 auto flag = 1<<((ri->d[rINDEX])/10000);
13566 229038 ffcdata& ff = tmpscr->ffcs[ri->ffcref];
13567
2/2
✓ Branch 0 taken 31750 times.
✓ Branch 1 taken 197288 times.
229038 SETFLAG(ff.flags, flag, value);
13568
4/4
✓ Branch 0 taken 225801 times.
✓ Branch 1 taken 3237 times.
✓ Branch 2 taken 3407 times.
✓ Branch 3 taken 222394 times.
229038 if (flag == ffSOLID || flag == ffCHANGER)
13569 6644 ff.updateSolid();
13570 229038 }
13571 229038 break;
13572
13573 case FFCWIDTH:
13574
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3248 times.
3248 if(BC::checkFFC(ri->ffcref, "ffc->EffectWidth") == SH::_NoError)
13575 3248 tmpscr->ffcs[ri->ffcref].hit_width = (value/10000);
13576 3248 break;
13577
13578 case FFCHEIGHT:
13579
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3250 times.
3250 if(BC::checkFFC(ri->ffcref, "ffc->EffectHeight") == SH::_NoError)
13580 3250 tmpscr->ffcs[ri->ffcref].hit_height = (value/10000);
13581 3250 break;
13582
13583 case FFTWIDTH:
13584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9502 times.
9502 if(BC::checkFFC(ri->ffcref, "ffc->TileWidth") == SH::_NoError)
13585 9502 tmpscr->ffcs[ri->ffcref].txsz = vbound(value/10000, 1, 4);
13586 9502 break;
13587
13588 case FFTHEIGHT:
13589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9512 times.
9512 if(BC::checkFFC(ri->ffcref, "ffc->TileHeight") == SH::_NoError)
13590 9512 tmpscr->ffcs[ri->ffcref].tysz = vbound(value/10000, 1, 4);
13591 9512 break;
13592
13593 case FFLINK:
13594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 616 times.
616 if(BC::checkFFC(ri->ffcref, "ffc->Link") == SH::_NoError)
13595 616 (tmpscr->ffcs[ri->ffcref].link)=vbound(value/10000, 0, MAXFFCS); // Allow "ffc->Link = 0" to unlink ffc.
13596 //0 is none, setting this before made it impssible to clear it. -Z
13597 616 break;
13598
13599 case FFMISCD:
13600 {
13601 900 int32_t a = vbound(ri->d[rINDEX]/10000,0,15);
13602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 900 times.
900 if(BC::checkFFC(ri->ffcref, "ffc->Misc[]")== SH::_NoError)
13603 900 ffmisc[ri->ffcref][a]=value;
13604 900 break;
13605 }
13606
13607 case FFINITDD:
13608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17706 times.
17706 if(BC::checkFFC(ri->ffcref, "ffc->InitD[]") == SH::_NoError)
13609 17706 (tmpscr->ffcs[ri->ffcref].initd[vbound(ri->d[rINDEX]/10000,0,7)])=value;
13610 17706 break;
13611
13612 case FFCLASTCHANGERX:
13613 if(BC::checkFFC(ri->ffcref, "ffc->LastChangerX") == SH::_NoError)
13614 ffposx[ri->ffcref]=vbound(zslongToFix(value).getInt(),-32768, 32767);
13615 break;
13616
13617 case FFCLASTCHANGERY:
13618 if(BC::checkFFC(ri->ffcref, "ffc->LastChangerY") == SH::_NoError)
13619 ffposy[ri->ffcref]=vbound(zslongToFix(value).getInt(),-32768, 32767);
13620 break;
13621
13622
13623
13624 ///----------------------------------------------------------------------------------------------------//
13625 //Hero's Variables
13626 case LINKX:
13627 {
13628
2/2
✓ Branch 0 taken 1210 times.
✓ Branch 1 taken 443391 times.
444601 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
13629 {
13630 1210 Hero.setXfix(zslongToFix(value));
13631 1210 }
13632 else
13633 {
13634 443391 Hero.setX(value/10000);
13635 }
13636 }
13637 444601 break;
13638
13639 case LINKCSET:
13640 {
13641 Hero.cs = value/10000;
13642 break;
13643 }
13644 case LINKY:
13645 {
13646
2/2
✓ Branch 0 taken 1071 times.
✓ Branch 1 taken 457869 times.
458940 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
13647 {
13648 1071 Hero.setYfix(zslongToFix(value));
13649 1071 }
13650 else
13651 {
13652 457869 Hero.setY(value/10000);
13653 }
13654 }
13655 458940 break;
13656
13657 case LINKZ:
13658 {
13659
2/2
✓ Branch 0 taken 2767 times.
✓ Branch 1 taken 2 times.
2769 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
13660 {
13661 2767 Hero.setZfix(zslongToFix(value));
13662 2767 }
13663 else
13664 {
13665 2 Hero.setZ(value/10000);
13666 }
13667 }
13668 2769 break;
13669
13670 case LINKJUMP:
13671 64379 Hero.setFall(zslongToFix(value) * -100);
13672 64379 break;
13673
13674 case HEROFAKEJUMP:
13675 Hero.setFakeFall(zslongToFix(value) * -100);
13676 break;
13677
13678 case LINKDIR:
13679 {
13680 //Hero->setDir() calls reset_hookshot(), which removes the sword sprite.. O_o
13681
3/4
✓ Branch 0 taken 93219 times.
✓ Branch 1 taken 475 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93219 times.
93694 if(Hero.getAction() == attacking || Hero.getAction() == sideswimattacking) Hero.dir = (value/10000);
13682 93219 else Hero.setDir(value/10000);
13683
13684 93694 break;
13685 }
13686
13687 case LINKHITDIR:
13688 Hero.setHitDir(value / 10000);
13689 break;
13690
13691 case LINKGRAVITY:
13692 if(value)
13693 Hero.moveflags |= FLAG_OBEYS_GRAV;
13694 else
13695 Hero.moveflags &= ~FLAG_OBEYS_GRAV;
13696 break;
13697
13698 case HERONOSTEPFORWARD:
13699 FFCore.nostepforward = ( (value) ? 1 : 0 );
13700 break;
13701
13702 case LINKHP:
13703
6/6
✓ Branch 0 taken 174180 times.
✓ Branch 1 taken 96373 times.
✓ Branch 2 taken 26 times.
✓ Branch 3 taken 270527 times.
✓ Branch 4 taken 174154 times.
✓ Branch 5 taken 96373 times.
270553 game->set_life(zc_max(0, zc_min(value/10000,game->get_maxlife())));
13704 270553 break;
13705
13706 case LINKMP:
13707
6/6
✓ Branch 0 taken 4662 times.
✓ Branch 1 taken 5753 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 10414 times.
✓ Branch 4 taken 4661 times.
✓ Branch 5 taken 5753 times.
10415 game->set_magic(zc_max(0, zc_min(value/10000,game->get_maxmagic())));
13708 10415 break;
13709
13710 case LINKMAXHP:
13711 56 game->set_maxlife(value/10000);
13712 56 break;
13713
13714 case LINKMAXMP:
13715 game->set_maxmagic(value/10000);
13716 break;
13717
13718 case LINKACTION:
13719 {
13720 388 int32_t act = value / 10000;
13721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 388 times.
388 switch(act)
13722 {
13723 case hookshotout:
13724 case stunned:
13725 case ispushing:
13726 FFCore.setHeroAction(act);
13727 break;
13728 default:
13729 388 Hero.setAction((actiontype)(act));
13730 388 }
13731 //Protect from writing illegal actions to Hero's raw variable.
13732 //in the future, we can move all scripted actions that are not possible
13733 //to set in ZC into this mechanic. -Z
13734 388 break;
13735 }
13736
13737 case HEROHEALTHBEEP:
13738 {
13739 int32_t beep = vbound((value/10000),-4, 255);
13740 //-2 suspends system control of stopping the sound
13741 //-3 suspends system control of stopping the sound AND suspends
13742 // system control over starting or playing it.
13743 heart_beep_timer = beep;
13744 if ( heart_beep_timer > -1 )
13745 {
13746 cont_sfx(QMisc.miscsfx[sfxLOWHEART]);
13747 }
13748 else
13749 {
13750 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
13751 }
13752 break;
13753 }
13754
13755 case LINKHELD:
13756 Hero.setHeldItem(vbound(value/10000,0,MAXITEMS-1));
13757 break;
13758
13759 case HEROSTEPS:
13760 {
13761 lsteps[vbound(ri->d[rINDEX]/10000,0,7)] = value/10000;
13762 break;
13763 }
13764
13765 case HEROSTEPRATE:
13766 if(!get_qr(qr_NEW_HERO_MOVEMENT))
13767 {
13768 Z_scripterrlog("To use '%s', you must %s the quest rule '%s'.", "Hero->Step", "enable", "New Player Movement");
13769 }
13770 Hero.setStepRate(zc_max(value/10000,0));
13771 if(!get_qr(qr_SCRIPT_WRITING_HEROSTEP_DOESNT_CARRY_OVER))
13772 zinit.heroStep = Hero.getStepRate();
13773 break;
13774
13775 case LINKITEMD:
13776 {
13777 5906 int32_t itemID=vbound(ri->d[rINDEX]/10000,0,MAXITEMS-1);
13778
13779 // If the Cane of Byrna is being removed, cancel its effect.
13780
3/4
✓ Branch 0 taken 3219 times.
✓ Branch 1 taken 2687 times.
✓ Branch 2 taken 3219 times.
✗ Branch 3 not taken.
5906 if(value==0 && itemID==current_item_id(itype_cbyrna))
13781 stopCaneOfByrna();
13782
13783 5906 auto& data = get_script_engine_data(ScriptType::Item, itemID);
13784
13785 //Stop current script if set false.
13786
4/4
✓ Branch 0 taken 3219 times.
✓ Branch 1 taken 2687 times.
✓ Branch 2 taken 3203 times.
✓ Branch 3 taken 16 times.
5906 if ( !value && data.doscript )
13787 {
13788 16 data.doscript = 4; //Val of 4 means 'clear stack and quit'
13789 //itemScriptData[itemID].Clear(); //Don't clear here, causes crash if is current item!
13790 16 }
13791
4/4
✓ Branch 0 taken 2687 times.
✓ Branch 1 taken 3203 times.
✓ Branch 2 taken 42 times.
✓ Branch 3 taken 2645 times.
5890 else if ( value && !data.doscript )
13792 {
13793 //Clear the item refInfo and stack for use.
13794 2645 data.ref.Clear();
13795
1/2
✓ Branch 0 taken 2645 times.
✗ Branch 1 not taken.
2645 if ( (itemsbuf[itemID].flags&ITEM_PASSIVESCRIPT) ) data.doscript = 1;
13796 2645 }
13797
3/4
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 3203 times.
✓ Branch 2 taken 42 times.
✗ Branch 3 not taken.
3245 else if ( value && data.doscript == 4 )
13798 {
13799 // Arbitrary event number 49326: Writing the item false, then true, in the same frame. -Z
13800 if ( (itemsbuf[itemID].flags&ITEM_PASSIVESCRIPT) ) data.doscript = 1;
13801 }
13802
13803 5906 bool settrue = ( value != 0 );
13804
13805 //Sanity check to prevent setting the item if the value would be the same. -Z
13806
2/2
✓ Branch 0 taken 3834 times.
✓ Branch 1 taken 2072 times.
5906 if ( game->item[itemID] != settrue )
13807 {
13808 2072 game->set_item(itemID,(value != 0));
13809 2072 }
13810
13811
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 5906 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5906 if((get_qr(qr_OVERWORLDTUNIC) != 0) || (currscr<128 || dlevel))
13812 {
13813 5906 ringcolor(false);
13814 //refreshpal=true;
13815 5906 }
13816
2/2
✓ Branch 0 taken 2687 times.
✓ Branch 1 taken 3219 times.
5906 if ( !value ) //setting the item false clears the state of forced ->Equipment writes.
13817 {
13818
1/2
✓ Branch 0 taken 3219 times.
✗ Branch 1 not taken.
3219 if ( game->forced_bwpn == itemID )
13819 {
13820 game->forced_bwpn = -1;
13821 } //not else if! -Z
13822
2/2
✓ Branch 0 taken 3218 times.
✓ Branch 1 taken 1 times.
3219 if ( game->forced_awpn == itemID )
13823 {
13824 1 game->forced_awpn = -1;
13825 1 }
13826
2/2
✓ Branch 0 taken 3216 times.
✓ Branch 1 taken 3 times.
3219 if ( game->forced_xwpn == itemID )
13827 {
13828 3 game->forced_xwpn = -1;
13829 3 }
13830
2/2
✓ Branch 0 taken 3216 times.
✓ Branch 1 taken 3 times.
3219 if ( game->forced_ywpn == itemID )
13831 {
13832 3 game->forced_ywpn = -1;
13833 3 }
13834 3219 }
13835 }
13836 5906 break;
13837
13838 case LINKEQUIP:
13839 {
13840 if ( FFCore.getQuestHeaderInfo(vZelda) == 0x250 && FFCore.getQuestHeaderInfo(vBuild) < 33 )
13841 {
13842 break;
13843 }
13844 //int32_t seta = (value/10000) >> 8; int32_t setb = value/10000) & 0xFF;
13845 int32_t setb = ((value/10000)&0xFF00)>>8, seta = (value/10000)&0xFF;
13846 seta = vbound(seta,-1,255);
13847 setb = vbound(setb,-1,255);
13848 //zprint("A is: %d\n", seta);
13849 //zprint("A is: %d\n", setb);
13850
13851 Awpn = seta;
13852 game->awpn = seta;
13853 game->forced_awpn = seta;
13854 game->items_off[seta] = 0;
13855 directItemA = seta;
13856
13857 Bwpn = setb;
13858 game->bwpn = setb;
13859 game->forced_bwpn = setb;
13860 game->items_off[setb] = 0;
13861 directItemB = seta;
13862 break;
13863 }
13864
13865
13866 case SETITEMSLOT:
13867 {
13868 //ri->d[rINDEX2] = 1st arg
13869 //ri->d[rINDEX] = 2nd arg
13870 //value = third arg
13871 //int32_t item, int32_t slot, int32_t force
13872 int32_t itm = ri->d[rINDEX]/10000;
13873 itm = vbound(itm, -1, 255);
13874
13875 int32_t slot = ri->d[rINDEX2]/10000;
13876 int32_t force = ri->d[rEXP1]/10000;
13877
13878 zprint("SetItemSlot rid->[0] is (%i), trying to use for '%s'\n", itm, "itm");
13879 zprint("SetItemSlot rid->[1] is (%i), trying to use for '%s'\n", slot, "slot");
13880 zprint("SetItemSlot rid->[2] is (%i), trying to use for '%s'\n", force, "force");
13881
13882 //If we add more item buttons, slot should be an int32_t
13883 //and force shuld be an int32_t
13884
13885 /*
13886 For zScript,
13887 const int32_t ITM_REQUIRE_NONE = 0
13888 const int32_t ITM_REQUIRE_INVENTORY = 1
13889 const int32_t ITM_REQUIRE_A_SLOT_RULE = 2
13890 //Combine as flags
13891 */
13892 if ( force == 0 )
13893 {
13894 switch(slot)
13895 {
13896 case 0: //b
13897 Bwpn = itm;
13898 game->items_off[itm] = 0;
13899 game->bwpn = itm;
13900 game->forced_bwpn = itm;
13901 break;
13902
13903 case 1: //a
13904 Awpn = itm;
13905 game->items_off[itm] = 0;
13906 game->awpn = itm;
13907 game->forced_awpn = itm;
13908 break;
13909
13910 case 2: //x
13911 Xwpn = itm;
13912 game->items_off[itm] = 0;
13913 game->xwpn = itm;
13914 game->forced_xwpn = itm;
13915 break;
13916
13917 case 3: //y
13918 Ywpn = itm;
13919 game->items_off[itm] = 0;
13920 game->ywpn = itm;
13921 game->forced_ywpn = itm;
13922 break;
13923 }
13924 }
13925 else if ( force == 1 )
13926 {
13927 if (game->item[itm])
13928 {
13929 switch(slot)
13930 {
13931 case 0: //b
13932 Bwpn = itm;
13933 game->items_off[itm] = 0;
13934 game->bwpn = itm;
13935 game->forced_bwpn = itm;
13936 break;
13937
13938 case 1: //a
13939 Awpn = itm;
13940 game->items_off[itm] = 0;
13941 game->awpn = itm;
13942 game->forced_awpn = itm;
13943 break;
13944
13945 case 2: //x
13946 Xwpn = itm;
13947 game->items_off[itm] = 0;
13948 game->xwpn = itm;
13949 game->forced_xwpn = itm;
13950 break;
13951
13952 case 3: //y
13953 Ywpn = itm;
13954 game->items_off[itm] = 0;
13955 game->ywpn = itm;
13956 game->forced_ywpn = itm;
13957 break;
13958 }
13959 }
13960 }
13961 else if ( force == 2 )
13962 {
13963 switch(slot)
13964 {
13965 case 0: //b
13966 Bwpn = itm;
13967 game->items_off[itm] = 0;
13968 game->bwpn = itm;
13969 game->forced_bwpn = itm;
13970 break;
13971
13972 case 1: //a
13973 {
13974 if (get_qr(qr_SELECTAWPN))
13975 {
13976 Awpn = itm;
13977 game->items_off[itm] = 0;
13978 game->awpn = itm;
13979 game->forced_awpn = itm;
13980 }
13981 break;
13982 }
13983
13984 case 2: //x
13985 Xwpn = itm;
13986 game->items_off[itm] = 0;
13987 game->xwpn = itm;
13988 game->forced_xwpn = itm;
13989 break;
13990
13991 case 3: //y
13992 Ywpn = itm;
13993 game->items_off[itm] = 0;
13994 game->ywpn = itm;
13995 game->forced_ywpn = itm;
13996 break;
13997 }
13998 }
13999 else if ( force == 3 ) //Flag ITM_REQUIRE_INVENTORY + ITM_REQUIRE_SLOT_A_RULE
14000 {
14001 if ( game->item[itm] )
14002 {
14003 switch(slot)
14004 {
14005 case 0: //b
14006 Bwpn = itm;
14007 game->items_off[itm] = 0;
14008 game->bwpn = itm;
14009 game->forced_bwpn = itm;
14010 break;
14011
14012 case 1: //a
14013 {
14014 if (get_qr(qr_SELECTAWPN))
14015 {
14016 Awpn = itm;
14017 game->items_off[itm] = 0;
14018 game->awpn = itm;
14019 game->forced_awpn = itm;
14020 }
14021 break;
14022 }
14023
14024 case 2: //x
14025 Xwpn = itm;
14026 game->items_off[itm] = 0;
14027 game->xwpn = itm;
14028 game->forced_xwpn = itm;
14029 break;
14030
14031 case 3: //y
14032 Ywpn = itm;
14033 game->items_off[itm] = 0;
14034 game->ywpn = itm;
14035 game->forced_ywpn = itm;
14036 break;
14037 }
14038 }
14039 }
14040 }
14041 break;
14042
14043 case LINKINVIS:
14044 740 Hero.setDontDraw((value ? 2 : 0));
14045 740 break;
14046
14047 case LINKINVINC:
14048 1532 Hero.scriptcoldet=(value/10000);
14049 1532 break;
14050
14051 case LINKENGINEANIMATE:
14052 Hero.do_animation=(value ? 1 : 0);
14053 break;
14054
14055 case LINKSWORDJINX:
14056 4 Hero.setSwordClk(value/10000);
14057 4 break;
14058
14059 case LINKITEMJINX:
14060 5161 Hero.setItemClk(value/10000);
14061 5161 break;
14062
14063 case LINKDRUNK:
14064 Hero.setDrunkClock(value/10000);
14065 break;
14066
14067 case LINKMISCD:
14068 56626 Hero.miscellaneous[vbound(ri->d[rINDEX]/10000,0,31)] = value;
14069 56626 break;
14070
14071 case LINKHITBY:
14072 {
14073 int32_t indx = ri->d[rINDEX]/10000;
14074 switch(indx)
14075 {
14076 //screen index objects
14077 case 0:
14078 case 1:
14079 case 2:
14080 case 3:
14081 case 8:
14082 case 9:
14083 case 10:
14084 case 11:
14085 case 12:
14086 case 16:
14087 {
14088 Hero.sethitHeroUID(indx, (value/10000)); //Why the Flidd did I vbound this? UIDs are LONGs, with a starting value of 0.0001. Why did I allow it, in fact? -Z
14089 break;
14090 }
14091 //UIDs
14092 case 4:
14093 case 5:
14094 case 6:
14095 case 7:
14096 case 13:
14097 case 14:
14098 case 15:
14099 {
14100 Hero.sethitHeroUID(indx, value); //Why the Flidd did I vbound this? UIDs are LONGs, with a starting value of 0.0001. Why did I allow it, in fact? -Z
14101 break;
14102 }
14103 default: { al_trace("Invalid index passed to Player->HitBy[%d] /n", indx); break; }
14104 }
14105 break;
14106 }
14107
14108 case LINKDEFENCE:
14109 Hero.set_defence(vbound(ri->d[rINDEX]/10000,0,255), ((char)vbound((value/10000), 0, 255)));
14110 break;
14111
14112 case LINKHXOFS:
14113 (Hero.hxofs)=(zfix)(value/10000);
14114 break;
14115
14116 case LINKROTATION:
14117 if ( get_qr(qr_OLDSPRITEDRAWS) )
14118 {
14119 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
14120 "Player->Rotation");
14121 break;
14122 }
14123 (Hero.rotation)=(value/10000);
14124 break;
14125
14126 case LINKSCALE:
14127 {
14128 if ( get_qr(qr_OLDSPRITEDRAWS) )
14129 {
14130 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
14131 "Player->Scale");
14132 break;
14133 }
14134 (Hero.scale)=(value/100.0);
14135 //al_trace("Player.scale is: %d\n", Hero.scale);
14136 //al_trace("Trying to set Player.scale to: %d\n", value/100.0);
14137 break;
14138 }
14139
14140 case LINKHYOFS:
14141 (Hero.hyofs)=(zfix)(value/10000);
14142 break;
14143
14144 case LINKXOFS:
14145 (Hero.xofs)=(zfix)(value/10000);
14146 break;
14147
14148 case LINKYOFS:
14149
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280560 times.
280560 (Hero.yofs)=(zfix)(value/10000)+(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
14150 280560 break;
14151 case HEROTOTALDYOFFS:
14152 break; //READ-ONLY
14153
14154 case HEROSHADOWXOFS:
14155 (Hero.shadowxofs)=(zfix)(value/10000);
14156 break;
14157
14158 case HEROSHADOWYOFS:
14159 (Hero.shadowyofs)=(zfix)(value/10000);
14160 break;
14161
14162 case LINKZOFS:
14163 (Hero.zofs)=(zfix)(value/10000);
14164 break;
14165
14166 case LINKHXSZ:
14167 (Hero.hit_width)=(zfix)(value/10000);
14168 break;
14169
14170 case LINKHYSZ:
14171 (Hero.hit_height)=(zfix)(value/10000);
14172 break;
14173
14174 case LINKHZSZ:
14175 (Hero.hzsz)=(zfix)(value/10000);
14176 break;
14177
14178 case LINKTXSZ:
14179 (Hero.txsz)=(zfix)(value/10000);
14180 break;
14181
14182 case LINKTYSZ:
14183 (Hero.tysz)=(zfix)(value/10000);
14184 break;
14185
14186 case LINKTILE:
14187 (Hero.tile)=(zfix)(value/10000);
14188 break;
14189
14190 case LINKFLIP:
14191 (Hero.flip)=(zfix)(value/10000);
14192 break;
14193
14194
14195
14196 case LINKINVFRAME:
14197 Hero.setHClk( (int32_t)vbound((value/10000), 0, 214747) );
14198 break;
14199
14200 case LINKCANFLICKER:
14201 Hero.setCanFlicker((value/10000)?1:0);
14202 break;
14203
14204 case LINKHURTSFX:
14205 Hero.setHurtSFX( (int32_t)vbound((value/10000), 0, 255) );
14206 break;
14207
14208
14209 case LINKITEMB:
14210 {
14211
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93758 times.
93758 if ( value/10000 < -1 )
14212 {
14213 al_trace("Tried to write an invalid item ID to Player->ItemB: %d\n",value/10000);
14214 break;
14215 }
14216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93758 times.
93758 if ( value/10000 > MAXITEMS-1 )
14217 {
14218 al_trace("Tried to write an invalid item ID to Player->ItemB: %d\n",value/10000);
14219 break;
14220 }
14221 //Hero->setBButtonItem(vbound((value/10000),0,(MAXITEMS-1)));
14222
14223
2/2
✓ Branch 0 taken 93750 times.
✓ Branch 1 taken 8 times.
93758 if (Bwpn != (value/10000))
14224 {
14225 8 Bwpn = value/10000;
14226 8 int32_t wpndummy = BWeapon_to_Pos(Bwpn);
14227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if (wpndummy >= 0) game->bwpn = wpndummy;
14228 8 game->forced_bwpn = value/10000;
14229 8 game->items_off[value/10000] = 0;
14230 8 }
14231 93758 directItemB = value/10000;
14232 93758 break;
14233 }
14234
14235
14236 case LINKITEMA:
14237 {
14238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93759 times.
93759 if ( value/10000 < -1 )
14239 {
14240 Z_scripterrlog("Tried to write an invalid item ID to Player->ItemA: %d\n",value/10000);
14241 break;
14242 }
14243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93759 times.
93759 if ( value/10000 > MAXITEMS-1 )
14244 {
14245 Z_scripterrlog("Tried to write an invalid item ID to Player->ItemA: %d\n",value/10000);
14246 break;
14247 }
14248 //Hero->setBButtonItem(vbound((value/10000),0,(MAXITEMS-1)));
14249
2/2
✓ Branch 0 taken 93752 times.
✓ Branch 1 taken 7 times.
93759 if (Awpn != (value/10000))
14250 {
14251 7 Awpn = value/10000;
14252 7 int32_t wpndummy = BWeapon_to_Pos(Awpn);
14253
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 4 times.
7 if (wpndummy >= 0) game->awpn = wpndummy;
14254 7 game->items_off[value/10000] = 0;
14255 7 game->forced_awpn = value/10000;
14256 7 }
14257 93759 directItemA = value/10000;
14258 93759 break;
14259 }
14260
14261 case LINKITEMX:
14262 {
14263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93772 times.
93772 if ( value/10000 < -1 )
14264 {
14265 Z_scripterrlog("Tried to write an invalid item ID to Player->ItemX: %d\n",value/10000);
14266 break;
14267 }
14268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93772 times.
93772 if ( value/10000 > MAXITEMS-1 )
14269 {
14270 Z_scripterrlog("Tried to write an invalid item ID to Player->ItemX: %d\n",value/10000);
14271 break;
14272 }
14273 //Hero->setBButtonItem(vbound((value/10000),0,(MAXITEMS-1)));
14274
2/2
✓ Branch 0 taken 93739 times.
✓ Branch 1 taken 33 times.
93772 if (Xwpn != (value/10000))
14275 {
14276 33 Xwpn = value/10000;
14277 33 int32_t wpndummy = BWeapon_to_Pos(Xwpn);
14278
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 23 times.
33 if (wpndummy >= 0) game->xwpn = wpndummy;
14279 33 game->items_off[value/10000] = 0;
14280 33 game->forced_xwpn = value/10000;
14281 33 }
14282 93772 directItemX = value/10000;
14283 93772 break;
14284 }
14285 case LINKITEMY:
14286 {
14287
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93778 times.
93778 if ( value/10000 < -1 )
14288 {
14289 Z_scripterrlog("Tried to write an invalid item ID to Player->ItemY: %d\n",value/10000);
14290 break;
14291 }
14292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93778 times.
93778 if ( value/10000 > MAXITEMS-1 )
14293 {
14294 Z_scripterrlog("Tried to write an invalid item ID to Player->ItemY: %d\n",value/10000);
14295 break;
14296 }
14297 //Hero->setBButtonItem(vbound((value/10000),0,(MAXITEMS-1)));
14298
2/2
✓ Branch 0 taken 93735 times.
✓ Branch 1 taken 43 times.
93778 if (Ywpn != (value/10000))
14299 {
14300 43 Ywpn = value/10000;
14301 43 int32_t wpndummy = BWeapon_to_Pos(Ywpn);
14302
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 37 times.
43 if (wpndummy >= 0) game->ywpn = wpndummy;
14303 43 game->items_off[value/10000] = 0;
14304 43 game->forced_ywpn = value/10000;
14305 43 }
14306 93778 directItemY = value/10000;
14307 93778 break;
14308 }
14309
14310
14311 case LINKEATEN:
14312 Hero.setEaten(value/10000);
14313 break;
14314 case LINKGRABBED:
14315 Hero.inwallm = value != 0;
14316 break;
14317 case HEROBUNNY:
14318 Hero.setBunnyClock(value/10000);
14319 break;
14320 case LINKPUSH:
14321 Hero.pushing = zc_max((value/10000),0);
14322 break;
14323 case LINKSTUN:
14324 Hero.setStunClock(value/10000);
14325 break;
14326 case LINKSCRIPTTILE:
14327 2569 script_hero_sprite=vbound((value/10000), -1, NEWMAXTILES-1);
14328 2569 break;
14329
14330 case HEROSCRIPTCSET:
14331 script_hero_cset=vbound((value/10000), -1, 0xF);
14332 break;
14333 case LINKSCRIPFLIP:
14334 2569 script_hero_flip=vbound((value/10000),-1,256);
14335 2569 break;
14336
14337 case GAMESETA:
14338 {
14339 //int32_t state = (ri->d[rINDEX2]/10000);
14340 //int32_t extend = (ri->d[rINDEX2]/10000);
14341 //int32_t dir = (ri->d[rINDEX]/10000);
14342 Z_message("Trying to force-set the A-button item().\n");
14343 Hero.setAButtonItem(vbound((value/10000),0,(MAXITEMS-1)));
14344 }
14345 break;
14346
14347 case GAMESETB:
14348 {
14349 //int32_t state = (ri->d[rINDEX2]/10000);
14350 //int32_t extend = (ri->d[rINDEX2]/10000);
14351 //int32_t dir = (ri->d[rINDEX]/10000);
14352 Z_message("Trying to force-set the A-button item().\n");
14353 Hero.setBButtonItem(vbound((value/10000),0,(MAXITEMS-1)));
14354 }
14355 break;
14356
14357 //Set Hero Diagonal
14358 case LINKDIAG:
14359 Hero.setDiagMove(value?1:0);
14360 set_qr(qr_LTTPWALK, value?1:0);
14361 break;
14362
14363 //Set Hero Big Hitbox
14364 case LINKBIGHITBOX:
14365 Hero.setBigHitbox((value/10000)?1:0);
14366 set_qr(qr_LTTPCOLLISION, (value/10000)?1:0);
14367 break;
14368
14369 case LINKCLIMBING:
14370 Hero.setOnSideviewLadder(value!=0?true:false);
14371 break;
14372
14373 case HEROJUMPCOUNT:
14374 Hero.extra_jump_count = value/10000;
14375 break;
14376
14377 case HEROPULLCLK:
14378 Hero.pit_pullclk = value/10000;
14379 break;
14380 case HEROFALLCLK:
14381 {
14382 int32_t val = vbound(value/10000,0,70);
14383 if(val)
14384 Hero.setAction(falling);
14385 else if(Hero.action == falling)
14386 {
14387 Hero.setAction(none);
14388 }
14389 Hero.fallclk = val;
14390 break;
14391 }
14392 case HEROFALLCMB:
14393 Hero.fallCombo = vbound(value/10000,0,MAXCOMBOS-1);
14394 break;
14395 case HERODROWNCLK:
14396 {
14397 int32_t val = vbound(value/10000,0,70);
14398 if(val)
14399 {
14400 if (Hero.action != lavadrowning) Hero.setAction(drowning);
14401 }
14402 else if(Hero.action == drowning || Hero.action == lavadrowning)
14403 {
14404 Hero.setAction(none);
14405 }
14406 Hero.drownclk = val;
14407 break;
14408 }
14409 case HERODROWNCMB:
14410 Hero.drownCombo = vbound(value/10000,0,MAXCOMBOS-1);
14411 break;
14412 case HEROFAKEZ:
14413 {
14414 if ( get_qr(qr_SPRITEXY_IS_FLOAT) )
14415 {
14416 Hero.setFakeZfix(zslongToFix(value));
14417 }
14418 else
14419 {
14420 Hero.setFakeZ(value/10000);
14421 }
14422 }
14423 break;
14424 case HEROMOVEFLAGS:
14425 {
14426 166 int32_t indx = ri->d[rINDEX]/10000;
14427
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 166 times.
166 if(BC::checkBounds(indx, 0, 10, "Hero->MoveFlags[]") == SH::_NoError)
14428 {
14429 //All bits, in order, of a single byte; just use bitwise
14430 166 int32_t bit = 1<<indx;
14431
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 165 times.
166 if(value)
14432 1 Hero.moveflags |= bit;
14433 else
14434 165 Hero.moveflags &= ~bit;
14435 166 }
14436 166 break;
14437 }
14438 case HEROLIFTFLAGS:
14439 {
14440 int32_t indx = ri->d[rINDEX]/10000;
14441 if(BC::checkBounds(indx, 0, NUM_LIFTFL-1, "Hero->LiftFlags[]") == SH::_NoError)
14442 {
14443 int32_t bit = 1<<indx;
14444 if(value)
14445 Hero.liftflags |= bit;
14446 else
14447 Hero.liftflags &= ~bit;
14448 }
14449 break;
14450 }
14451
14452 case HEROSHIELDJINX:
14453 Hero.shieldjinxclk = value/10000;
14454 break;
14455
14456 case CLOCKACTIVE:
14457 {
14458 Hero.setClock(watch=(value?true:false));
14459 break;
14460 }
14461
14462 case CLOCKCLK:
14463 clockclk = vbound((value/10000), 0, 214748);
14464 break;
14465
14466 case HERORESPAWNX:
14467 {
14468 zfix zx = zslongToFix(value);
14469 Hero.respawn_x = vbound(zx, 0, 240);
14470 break;
14471 }
14472
14473 case HERORESPAWNY:
14474 {
14475 zfix zy = zslongToFix(value);
14476 Hero.respawn_y = vbound(zy, 0, 160);
14477 break;
14478 }
14479
14480 case HERORESPAWNDMAP:
14481 {
14482 Hero.respawn_dmap = vbound(value/10000, 0, MAXDMAPS-1);
14483 break;
14484 }
14485
14486 case HERORESPAWNSCR:
14487 {
14488 Hero.respawn_scr = vbound(value/10000, 0, 0x7F);
14489 break;
14490 }
14491
14492
14493 case HEROSWITCHMAXTIMER:
14494 case HEROSWITCHTIMER:
14495 break; //read-only
14496
14497 case HEROIMMORTAL:
14498 {
14499 Hero.setImmortal(value/10000);
14500 break;
14501 }
14502
14503 case HEROCOYOTETIME:
14504 {
14505 auto v = value/10000;
14506 if(v < 0 || v > 65535) v = 65535;
14507 Hero.coyotetime = word(v);
14508 break;
14509 }
14510 case HEROLIFTEDWPN:
14511 {
14512 if(Hero.lift_wpn)
14513 {
14514 delete Hero.lift_wpn;
14515 Hero.lift_wpn = nullptr;
14516 }
14517 if(value)
14518 {
14519 if(weapon* wpn = checkLWpn(value,"Hero->LiftedWeapon"))
14520 {
14521 if(wpn == Hero.lift_wpn) break;
14522 Hero.lift_wpn = wpn;
14523 if(Lwpns.find(wpn) > -1)
14524 Lwpns.remove(wpn);
14525 if(curScriptType == ScriptType::Lwpn && value == curScriptIndex)
14526 earlyretval = RUNSCRIPT_SELFREMOVE;
14527 }
14528 }
14529 break;
14530 }
14531 case HEROLIFTTIMER:
14532 {
14533 Hero.liftclk = value/10000;
14534 break;
14535 }
14536 case HEROLIFTMAXTIMER:
14537 {
14538 Hero.tliftclk = value/10000;
14539 break;
14540 }
14541 case HEROLIFTHEIGHT:
14542 {
14543 Hero.liftheight = zslongToFix(value);
14544 break;
14545 }
14546 case HEROHAMMERSTATE:
14547 {
14548 //readonly
14549 break;
14550 }
14551
14552
14553 ///----------------------------------------------------------------------------------------------------//
14554 //Input States
14555 case INPUTSTART:
14556 {
14557 928305 control_state[6]=(value?true:false);
14558
2/2
✓ Branch 0 taken 928224 times.
✓ Branch 1 taken 81 times.
928305 if ( get_qr(qr_FIXDRUNKINPUTS) ) drunk_toggle_state[6]=false;
14559 928305 break;
14560 }
14561
14562 case INPUTMAP:
14563 {
14564 461890 control_state[9]=(value?true:false);
14565
2/2
✓ Branch 0 taken 461809 times.
✓ Branch 1 taken 81 times.
461890 if ( get_qr(qr_FIXDRUNKINPUTS) )
14566 81 drunk_toggle_state[9]=false;
14567 461890 break;
14568 }
14569
14570 case INPUTUP:
14571 {
14572 249228 control_state[0]=(value?true:false);
14573
2/2
✓ Branch 0 taken 248029 times.
✓ Branch 1 taken 1199 times.
249228 if ( get_qr(qr_FIXDRUNKINPUTS) ) drunk_toggle_state[0]=false;
14574 249228 break;
14575 }
14576
14577 case INPUTDOWN:
14578 {
14579 249220 control_state[1]=(value?true:false);
14580
2/2
✓ Branch 0 taken 248027 times.
✓ Branch 1 taken 1193 times.
249220 if ( get_qr(qr_FIXDRUNKINPUTS) )
14581 1193 drunk_toggle_state[1]=false;
14582 249220 break;
14583 }
14584
14585 case INPUTLEFT:
14586 {
14587 236658 control_state[2]=(value?true:false);
14588
2/2
✓ Branch 0 taken 235481 times.
✓ Branch 1 taken 1177 times.
236658 if ( get_qr(qr_FIXDRUNKINPUTS) ) drunk_toggle_state[2]=false;
14589 236658 break;
14590 }
14591
14592 case INPUTRIGHT:
14593 {
14594 236880 control_state[3]=(value?true:false);
14595
2/2
✓ Branch 0 taken 235703 times.
✓ Branch 1 taken 1177 times.
236880 if ( get_qr(qr_FIXDRUNKINPUTS) ) drunk_toggle_state[3]=false;
14596 236880 break;
14597 }
14598
14599 case INPUTA:
14600 {
14601 89166 control_state[4]=(value?true:false);
14602
2/2
✓ Branch 0 taken 89113 times.
✓ Branch 1 taken 53 times.
89166 if ( get_qr(qr_FIXDRUNKINPUTS) ) drunk_toggle_state[4]=false;
14603 89166 break;
14604 }
14605
14606 case INPUTB:
14607 {
14608 76223 control_state[5]=(value?true:false);
14609
1/2
✓ Branch 0 taken 76223 times.
✗ Branch 1 not taken.
76223 if ( get_qr(qr_FIXDRUNKINPUTS) ) drunk_toggle_state[5]=false;
14610 76223 break;
14611 }
14612
14613 case INPUTL:
14614 {
14615 78737 control_state[7]=(value?true:false);
14616
2/2
✓ Branch 0 taken 78656 times.
✓ Branch 1 taken 81 times.
78737 if ( get_qr(qr_FIXDRUNKINPUTS) ) drunk_toggle_state[7]=false;
14617 78737 break;
14618 }
14619
14620 case INPUTR:
14621 {
14622 78784 control_state[8]=(value?true:false);
14623
2/2
✓ Branch 0 taken 78703 times.
✓ Branch 1 taken 81 times.
78784 if ( get_qr(qr_FIXDRUNKINPUTS) ) drunk_toggle_state[8]=false;
14624 78784 break;
14625 }
14626
14627 case INPUTEX1:
14628 {
14629 222649 control_state[10]=(value?true:false);
14630 222649 break;
14631 }
14632
14633 case INPUTEX2:
14634 222649 control_state[11]=(value?true:false);
14635 222649 break;
14636
14637 case INPUTEX3:
14638 222649 control_state[12]=(value?true:false);
14639 222649 break;
14640
14641 case INPUTEX4:
14642 222649 control_state[13]=(value?true:false);
14643 222649 break;
14644
14645 case INPUTAXISUP:
14646 control_state[14]=(value?true:false);
14647 break;
14648
14649 case INPUTAXISDOWN:
14650 control_state[15]=(value?true:false);
14651 break;
14652
14653 case INPUTAXISLEFT:
14654 control_state[16]=(value?true:false);
14655 break;
14656
14657 case INPUTAXISRIGHT:
14658 control_state[17]=(value?true:false);
14659 break;
14660
14661 case INPUTPRESSSTART:
14662 928305 button_press[6]=(value?true:false);
14663 928305 break;
14664
14665 case INPUTPRESSMAP:
14666 461890 button_press[9]=(value?true:false);
14667 461890 break;
14668
14669 case INPUTPRESSUP:
14670 218369 button_press[0]=(value?true:false);
14671 218369 break;
14672
14673 case INPUTPRESSDOWN:
14674 218364 button_press[1]=(value?true:false);
14675 218364 break;
14676
14677 case INPUTPRESSLEFT:
14678 218431 button_press[2]=(value?true:false);
14679 218431 break;
14680
14681 case INPUTPRESSRIGHT:
14682 218461 button_press[3]=(value?true:false);
14683 218461 break;
14684
14685 case INPUTPRESSA:
14686 83086 button_press[4]=(value?true:false);
14687 83086 break;
14688
14689 case INPUTPRESSB:
14690 70141 button_press[5]=(value?true:false);
14691 70141 break;
14692
14693 case INPUTPRESSL:
14694 75869 button_press[7]=(value?true:false);
14695 75869 break;
14696
14697 case INPUTPRESSR:
14698 75916 button_press[8]=(value?true:false);
14699 75916 break;
14700
14701 case INPUTPRESSEX1:
14702 222649 button_press[10]=(value?true:false);
14703 222649 break;
14704
14705 case INPUTPRESSEX2:
14706 222649 button_press[11]=(value?true:false);
14707 222649 break;
14708
14709 case INPUTPRESSEX3:
14710 222649 button_press[12]=(value?true:false);
14711 222649 break;
14712
14713 case INPUTPRESSEX4:
14714 222649 button_press[13]=(value?true:false);
14715 222649 break;
14716
14717 case INPUTPRESSAXISUP:
14718 button_press[14]=(value?true:false);
14719 break;
14720
14721 case INPUTPRESSAXISDOWN:
14722 button_press[15]=(value?true:false);
14723 break;
14724
14725 case INPUTPRESSAXISLEFT:
14726 button_press[16]=(value?true:false);
14727 break;
14728
14729 case INPUTPRESSAXISRIGHT:
14730 button_press[17]=(value?true:false);
14731 break;
14732
14733 case INPUTMOUSEX:
14734 {
14735 position_mouse(rti_game.local_to_global_x(value/10000), mouse_y);
14736 break;
14737 }
14738
14739 case INPUTMOUSEY:
14740 {
14741 int32_t mousequakeoffset = 56+((int32_t)(zc::math::Sin((double)(quakeclk*int64_t(2)-frame))*4));
14742 int32_t tempoffset = (quakeclk > 0) ? mousequakeoffset : (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
14743 position_mouse(mouse_x, rti_game.local_to_global_y(value/10000 + tempoffset));
14744 break;
14745 }
14746
14747 case INPUTMOUSEZ:
14748 position_mouse_z(value/10000);
14749 break;
14750
14751 case FFRULE:
14752 {
14753 int32_t ruleid = vbound((ri->d[rINDEX]/10000),0,qr_MAX);
14754 set_qr(ruleid, (value?true:false));
14755 switch(ruleid)
14756 {
14757 case qr_LTTPWALK:
14758 Hero.setDiagMove(value?1:0);
14759 break;
14760 case qr_LTTPCOLLISION:
14761 Hero.setBigHitbox(value?1:0);
14762 break;
14763 case qr_ZS_NO_NEG_ARRAY:
14764 can_neg_array = !value;
14765 break;
14766 }
14767 }
14768 break;
14769
14770 case BUTTONPRESS:
14771 // DUkey, DDkey, DLkey, DRkey, Akey, Bkey, Skey, Lkey, Rkey, Pkey, Exkey1, Exkey2, Exkey3, Exkey4 };
14772 {
14773 //Read-only
14774 281176 int32_t button = vbound((ri->d[rINDEX]/10000),0,17);
14775 281176 button_press[button]=(value?true:false);
14776
4/4
✓ Branch 0 taken 220924 times.
✓ Branch 1 taken 60252 times.
✓ Branch 2 taken 42471 times.
✓ Branch 3 taken 178453 times.
281176 if ( button < 11 && get_qr(qr_FIXDRUNKINPUTS) ) drunk_toggle_state[button]=false;
14777
14778 }
14779 281176 break;
14780
14781 case BUTTONINPUT:
14782 {
14783 //Read-only
14784 281262 int32_t button = vbound((ri->d[rINDEX]/10000),0,17);
14785 281262 control_state[button]=(value?true:false);
14786
4/4
✓ Branch 0 taken 221010 times.
✓ Branch 1 taken 60252 times.
✓ Branch 2 taken 42557 times.
✓ Branch 3 taken 178453 times.
281262 if ( button < 11 && get_qr(qr_FIXDRUNKINPUTS) ) drunk_toggle_state[button]=false;
14787 }
14788 281262 break;
14789
14790 case BUTTONHELD:
14791 {
14792 //Read-only
14793 int32_t button = vbound((ri->d[rINDEX]/10000),0,17);
14794 button_hold[button]=(value?true:false);
14795 }
14796 break;
14797
14798 case RAWKEY:
14799 { //Game->KeyPressed[], read-only
14800 //if ( !keypressed() ) break; //Don;t return values set by setting Hero->Input/Press
14801 //hmm...no, this won;t return properly for modifier keys.
14802 int32_t keyid = ri->d[rINDEX]/10000;
14803 //key = vbound(key,0,n);
14804 _key[keyid]=key[keyid]=key_current_frame[keyid]=(value?true:false); //It isn't possible to set keys true, because polling occurs before they are set?
14805 //but they *can* be set false; ??? -Z
14806 }
14807 break;
14808
14809 case KEYINPUT:
14810 {
14811 KeyInput[ri->d[rINDEX]/10000] = (value/10000)!=0;
14812 switch(ri->d[rINDEX]/10000)
14813 {
14814 case KEY_F6: onTryQuit(); break;
14815 case KEY_F3: Paused = !Paused; break;
14816 case KEY_F4: Paused = true; Advance = true; break;
14817 }
14818 break;
14819 }
14820 case KEYPRESS:
14821 {
14822 KeyPress[ri->d[rINDEX]/10000] = (value/10000)!=0;
14823 break;
14824 }
14825
14826 case SIMULATEKEYPRESS:
14827 { //Game->KeyPressed[], read-only
14828 //if ( !keypressed() ) break; //Don;t return values set by setting Hero->Input/Press
14829 //hmm...no, this won;t return properly for modifier keys.
14830 int32_t keyid = ri->d[rINDEX]/10000;
14831 //key = vbound(key,0,n);
14832 if (value/10000) simulate_keypress(keyid << 8);
14833 }
14834 break;
14835
14836 case KEYMODIFIERS:
14837 {
14838 key_shifts = ( value/10000 );
14839 break;
14840 }
14841
14842 case KEYBINDINGS:
14843 {
14844 int32_t keyid = ri->d[rINDEX]/10000;
14845 switch(keyid)
14846 {
14847 case 0: DUkey = ( value/10000 ); break;
14848 case 1: DDkey = ( value/10000 ); break;
14849 case 2: DLkey = ( value/10000 ); break;
14850 case 3: DRkey = ( value/10000 ); break;
14851 case 4: Akey = ( value/10000 ); break;
14852 case 5: Bkey = ( value/10000 ); break;
14853 case 6: Skey = ( value/10000 ); break;
14854 case 7: Lkey = ( value/10000 ); break;
14855 case 8: Rkey = ( value/10000 ); break;
14856 case 9: Pkey = ( value/10000 ); /*map*/ break;
14857 case 10: Exkey1 = ( value/10000 ); break;
14858 case 11: Exkey2 = ( value/10000 ); break;
14859 case 12: Exkey3 = ( value/10000 ); break;
14860 case 13: Exkey4 = ( value/10000 ); break;
14861
14862 default: { Z_scripterrlog("Invalid index [%d] passed to Input->KeyBindings[]\n", keyid); break; }
14863 }
14864 break;
14865 }
14866
14867 case DISABLEKEY:
14868 {
14869 //Input->DisableKey(int32_t key, bool disable)
14870 int32_t keyid = ri->d[rINDEX]/10000;
14871 if(!zc_disablekey(keyid, value))
14872 {
14873 //Z_scripterrlog("The key %d passed to Input->DisableKey[] is system-reserved, and cannot be disabled\n",keyid);
14874 }
14875 break;
14876 }
14877
14878 case DISABLEBUTTON:
14879 {
14880 //Input->DisableButton(int32_t cb, bool disable)
14881 int32_t cbid = ri->d[rINDEX]/10000;
14882 disable_control[cbid] = value?true:false;
14883 break;
14884 }
14885
14886 case MOUSEARR:
14887 {
14888 int32_t indx = (ri->d[rINDEX]/10000);
14889 switch (indx)
14890 {
14891 case 0: //MouseX
14892 {
14893 position_mouse(rti_game.local_to_global_x(value/10000), mouse_y);
14894 break;
14895 }
14896 case 1: //MouseY
14897 {
14898 int32_t mousequakeoffset = 56+((int32_t)(zc::math::Sin((double)(quakeclk*int64_t(2)-frame))*4));
14899 int32_t tempoffset = (quakeclk > 0) ? mousequakeoffset :(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
14900 position_mouse(mouse_x, rti_game.local_to_global_y(value/10000 + tempoffset));
14901 break;
14902
14903 }
14904 case 2: //MouseZ
14905 {
14906 position_mouse_z(value/10000);
14907 break;
14908 }
14909 case 3: //Left Click
14910 {
14911 if ( value ) mouse_b |= 1;
14912 else mouse_b &= ~1;
14913 break;
14914 }
14915 case 4: //Right Click
14916 {
14917 if ( value ) mouse_b |= 2;
14918 else mouse_b &= ~2;
14919 break;
14920 }
14921 case 5: //Middle Click
14922 {
14923 if ( value ) mouse_b |= 4;
14924 else mouse_b &= ~4;
14925 break;
14926 }
14927 default:
14928 {
14929 Z_scripterrlog("Invalid index passed to Input->Mouse[]: %d\n", indx);
14930 }
14931 }
14932
14933 }
14934 break;
14935
14936
14937 ///----------------------------------------------------------------------------------------------------//
14938 //Item Variables
14939
14940 case ITEMFAMILY:
14941 if(0!=(s=checkItem(ri->itemref)))
14942 {
14943 (((item *)s)->family)=value/10000;
14944 }
14945
14946 break;
14947
14948 case ITEMLEVEL:
14949 if(0!=(s=checkItem(ri->itemref)))
14950 {
14951 (((item *)s)->lvl)=value/10000;
14952 }
14953
14954 break;
14955
14956 case SPRITEMAXITEM:
14957 {
14958 //No bounds check, as this is a universal function and works from NULL pointers!
14959 items.setMax(vbound((value/10000),1,MAX_ITEM_SPRITES));
14960 break;
14961 }
14962
14963 case ITEMX:
14964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21848 times.
21848 if(0!=(s=checkItem(ri->itemref)))
14965 {
14966
2/2
✓ Branch 0 taken 170 times.
✓ Branch 1 taken 21678 times.
21848 (s->x)=get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000);
14967
14968 // Move the Fairy enemy as well.
14969
3/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 21838 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
21848 if(itemsbuf[((item*)(s))->id].family==itype_fairy && itemsbuf[((item*)(s))->id].misc3)
14970 movefairynew2(((item*)(s))->x,((item*)(s))->y,*((item*)(s)));
14971 21848 }
14972
14973 21848 break;
14974
14975 case ITEMSPRITESCRIPT:
14976 31 FFScript::deallocateAllArrays(ScriptType::ItemSprite, ri->itemref);
14977
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if(0!=(s=checkItem(ri->itemref)))
14978 {
14979 31 (s->script)=(value/10000);
14980 31 }
14981 31 break;
14982
14983 case ITEMSCALE:
14984 if ( get_qr(qr_OLDSPRITEDRAWS) )
14985 {
14986 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
14987 "item->Scale");
14988 break;
14989 }
14990 if(0!=(s=checkItem(ri->itemref)))
14991 {
14992 (s->scale)=(zfix)(value/100.0);
14993 }
14994
14995 break;
14996
14997 case ITEMY:
14998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41791 times.
41791 if(0!=(s=checkItem(ri->itemref)))
14999 {
15000
2/2
✓ Branch 0 taken 1142 times.
✓ Branch 1 taken 40649 times.
41791 (s->y)=get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000);
15001
15002 // Move the Fairy enemy as well.
15003
3/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 41781 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
41791 if(itemsbuf[((item*)(s))->id].family==itype_fairy && itemsbuf[((item*)(s))->id].misc3)
15004 movefairynew2(((item*)(s))->x,((item*)(s))->y,*((item*)(s)));
15005 41791 }
15006
15007 41791 break;
15008
15009 case ITEMZ:
15010
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(0!=(s=checkItem(ri->itemref)))
15011 {
15012 92 (s->z)=(zfix)(value/10000);
15013
15014
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(s->z < 0)
15015 s->z = 0;
15016 92 }
15017
15018 92 break;
15019
15020 case ITEMJUMP:
15021
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49959 times.
49959 if(0!=(s=checkItem(ri->itemref)))
15022 {
15023 49959 (((item *)s)->fall)=zslongToFix(value)*-100;
15024 49959 }
15025
15026 49959 break;
15027
15028 case ITEMFAKEJUMP:
15029 if(0!=(s=checkItem(ri->itemref)))
15030 {
15031 (((item *)s)->fakefall)=zslongToFix(value)*-100;
15032 }
15033
15034 break;
15035
15036 case ITEMDRAWTYPE:
15037 if(0!=(s=checkItem(ri->itemref)))
15038 {
15039 (((item *)s)->drawstyle)=value/10000;
15040 }
15041
15042 break;
15043
15044 case ITEMSPRITEINITD:
15045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if(0!=(s=checkItem(ri->itemref)))
15046 {
15047 37 int32_t a = vbound(ri->d[rINDEX]/10000,0,7);
15048 37 (((item *)s)->initD[a])=value;
15049 37 }
15050
15051 37 break;
15052
15053 case ITEMGRAVITY:
15054 if(0!=(s=checkItem(ri->itemref)))
15055 {
15056 if(value)
15057 ((item *)s)->moveflags |= FLAG_OBEYS_GRAV;
15058 else
15059 ((item *)s)->moveflags &= ~FLAG_OBEYS_GRAV;
15060 }
15061
15062 break;
15063
15064 case ITEMID:
15065 if(0!=(s=checkItem(ri->itemref)))
15066 {
15067 (((item *)s)->id)=value/10000;
15068 flushItemCache();
15069 }
15070
15071 break;
15072
15073 case ITEMTILE:
15074
1/2
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
109 if(0!=(s=checkItem(ri->itemref)))
15075 {
15076 109 (((item *)s)->tile)=vbound(value/10000,0,NEWMAXTILES-1);
15077 109 }
15078
15079 109 break;
15080
15081 case ITEMSCRIPTTILE:
15082 if(0!=(s=checkItem(ri->itemref)))
15083 {
15084 (((item *)s)->scripttile)=vbound(value/10000,-1,NEWMAXTILES-1);
15085 }
15086 break;
15087
15088 case ITEMSCRIPTFLIP:
15089 if(0!=(s=checkItem(ri->itemref)))
15090 {
15091 (((item *)s)->scriptflip)=vbound((value/10000),-1,127);
15092 }
15093 break;
15094
15095 case ITEMPSTRING:
15096 if(0!=(s=checkItem(ri->itemref)))
15097 {
15098 (((item *)s)->pstring)=vbound(value/10000,0,(msg_count-1));
15099 }
15100
15101 break;
15102
15103 case ITEMPSTRINGFLAGS:
15104 if(0!=(s=checkItem(ri->itemref)))
15105 {
15106 (((item *)s)->pickup_string_flags)=vbound(value/10000, 0, 214748);
15107 }
15108
15109 break;
15110
15111 case ITEMOVERRIDEFLAGS:
15112 break;
15113
15114 case ITEMOTILE:
15115
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(0!=(s=checkItem(ri->itemref)))
15116 {
15117 40 (((item *)s)->o_tile)=vbound(value/10000,0,NEWMAXTILES-1);
15118 40 }
15119
15120 40 break;
15121
15122 case ITEMCSET:
15123 if(0!=(s=checkItem(ri->itemref)))
15124 {
15125 (((item *)s)->o_cset) = (((item *)s)->o_cset & ~15) | ((value/10000)&15);
15126 (((item *)s)->cs) = (((item *)s)->o_cset & 15);
15127 }
15128
15129 break;
15130
15131 case ITEMFLASHCSET:
15132 if(0!=(s=checkItem(ri->itemref)))
15133 {
15134 (((item *)s)->o_cset) = ((value/10000)<<4) | (((item *)s)->o_cset & 15);
15135 }
15136
15137 break;
15138
15139 case ITEMFRAMES:
15140 if(0!=(s=checkItem(ri->itemref)))
15141 {
15142 (((item *)s)->frames)=value/10000;
15143 }
15144
15145 break;
15146
15147 case ITEMFRAME:
15148 if(0!=(s=checkItem(ri->itemref)))
15149 {
15150 (((item *)s)->aframe)=value/10000;
15151 }
15152
15153 break;
15154
15155 case ITEMASPEED:
15156 if(0!=(s=checkItem(ri->itemref)))
15157 {
15158 (((item *)s)->o_speed)=value/10000;
15159 }
15160
15161 break;
15162
15163 case ITEMACLK:
15164 if(0!=(s=checkItem(ri->itemref)))
15165 {
15166 (((item *)s)->aclk)=value/10000;
15167 }
15168
15169 break;
15170
15171 case ITEMDELAY:
15172 if(0!=(s=checkItem(ri->itemref)))
15173 {
15174 (((item *)s)->o_delay)=value/10000;
15175 }
15176
15177 break;
15178
15179 case ITEMFLIP:
15180 if(0!=(s=checkItem(ri->itemref)))
15181 {
15182 (((item *)s)->flip)=value/10000;
15183 }
15184
15185 break;
15186
15187 case ITEMFLASH:
15188 if(0!=(s=checkItem(ri->itemref)))
15189 {
15190 (((item *)s)->flash)= (value/10000)?1:0;
15191 }
15192
15193 break;
15194
15195 case ITEMEXTEND:
15196 if(0!=(s=checkItem(ri->itemref)))
15197 {
15198 (((item *)s)->extend)=value/10000;
15199 }
15200
15201 break;
15202
15203 case ITEMHXOFS:
15204 if(0!=(s=checkItem(ri->itemref)))
15205 {
15206 ((item*)(s))->hxofs=value/10000;
15207 }
15208
15209 break;
15210
15211 case ITEMROTATION:
15212 if ( get_qr(qr_OLDSPRITEDRAWS) )
15213 {
15214 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
15215 "item->Rotation");
15216 break;
15217 }
15218 if(0!=(s=checkItem(ri->itemref)))
15219 {
15220 ((item*)(s))->rotation=value/10000;
15221 }
15222
15223 break;
15224
15225 case ITEMHYOFS:
15226 if(0!=(s=checkItem(ri->itemref)))
15227 {
15228 ((item*)(s))->hyofs=value/10000;
15229 }
15230
15231 break;
15232
15233 case ITEMXOFS:
15234 if(0!=(s=checkItem(ri->itemref)))
15235 {
15236 ((item*)(s))->xofs=(zfix)(value/10000);
15237 }
15238
15239 break;
15240
15241 case ITEMYOFS:
15242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(0!=(s=checkItem(ri->itemref)))
15243 {
15244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 ((item*)(s))->yofs=(zfix)(value/10000)+(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
15245 6 }
15246
15247 6 break;
15248
15249 case ITEMSHADOWXOFS:
15250 if(0!=(s=checkItem(ri->itemref)))
15251 {
15252 ((item*)(s))->shadowxofs=(zfix)(value/10000);
15253 }
15254
15255 break;
15256
15257 case ITEMSHADOWYOFS:
15258 if(0!=(s=checkItem(ri->itemref)))
15259 {
15260 ((item*)(s))->shadowyofs=(zfix)(value/10000);
15261 }
15262
15263 break;
15264
15265 case ITEMZOFS:
15266 if(0!=(s=checkItem(ri->itemref)))
15267 {
15268 ((item*)(s))->zofs=(zfix)(value/10000);
15269 }
15270
15271 break;
15272
15273 case ITEMHXSZ:
15274 if(0!=(s=checkItem(ri->itemref)))
15275 {
15276 ((item*)(s))->hit_width=value/10000;
15277 }
15278
15279 break;
15280
15281 case ITEMHYSZ:
15282 if(0!=(s=checkItem(ri->itemref)))
15283 {
15284 ((item*)(s))->hit_height=value/10000;
15285 }
15286
15287 break;
15288
15289 case ITEMHZSZ:
15290 if(0!=(s=checkItem(ri->itemref)))
15291 {
15292 ((item*)(s))->hzsz=value/10000;
15293 }
15294
15295 break;
15296
15297 case ITEMTXSZ:
15298 if(0!=(s=checkItem(ri->itemref)))
15299 {
15300 ((item*)(s))->txsz=vbound((value/10000),1,20);
15301 }
15302
15303 break;
15304
15305 case ITEMTYSZ:
15306 if(0!=(s=checkItem(ri->itemref)))
15307 {
15308 ((item*)(s))->tysz=vbound((value/10000),1,20);
15309 }
15310
15311 break;
15312
15313 case ITEMPICKUP:
15314
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 1181 times.
787 if(0!=(s=checkItem(ri->itemref)))
15315 {
15316 1181 int32_t newpickup = value/10000;
15317 // Values that the questmaker should not use, ever
15318 //Allowing it, for now, until something breaks. -Z 21-Jan-2020
15319 //newpickup &= ~(ipBIGRANGE | ipCHECK | ipMONEY | ipBIGTRI | ipNODRAW | ipFADE);
15320 //
15321
4/4
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 461 times.
✓ Branch 2 taken 197 times.
✓ Branch 3 taken 264 times.
1181 if (( FFCore.GetQuestVersion() == 0x250 && FFCore.GetQuestBuild() < 33 ) //this ishowit looks in 2.53.1, Beta 25
15322 1181 || ( FFCore.GetQuestVersion() < 0x250 ))
15323 {
15324 917 newpickup &= ~(ipBIGRANGE | ipCHECK | ipMONEY | ipBIGTRI | ipNODRAW | ipFADE);
15325 917 }
15326
15327 // If making an item timeout, set its timer
15328
2/2
✓ Branch 0 taken 717 times.
✓ Branch 1 taken 70 times.
787 if(newpickup & ipFADE)
15329 {
15330 70 (((item*)(s))->clk2) = 512;
15331 70 }
15332 //else if(newpickup & ~ipFADE)
15333 //{
15334 // (((item*)(s))->clk2) = 0;
15335 //}
15336
15337 // If making it a carried item,
15338 // alter hasitem and set an itemguy.
15339
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 787 times.
787 if((((item*)(s))->pickup & ipENEMY) < (newpickup & ipENEMY))
15340 {
15341 hasitem |= 2;
15342 bool hasitemguy = false;
15343
15344 for(int32_t i=0; i<guys.Count(); i++)
15345 {
15346 if(((enemy*)guys.spr(i))->itemguy)
15347 {
15348 hasitemguy = true;
15349 }
15350 }
15351
15352 if(!hasitemguy && guys.Count()>0)
15353 {
15354 ((enemy*)guys.spr(guys.Count()-1))->itemguy = true;
15355 }
15356 }
15357 // If unmaking it a carried item,
15358 // alter hasitem if there are no more carried items.
15359
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 else if((((item*)(s))->pickup & ipENEMY) > (newpickup & ipENEMY))
15360 {
15361 // Move it back onscreen!
15362 if(get_qr(qr_HIDECARRIEDITEMS))
15363 {
15364 for(int32_t i=0; i<guys.Count(); i++)
15365 {
15366 if(((enemy*)guys.spr(i))->itemguy)
15367 {
15368 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
15369 {
15370 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
15371 {
15372 ((item*)(s))->x = ((enemy*)guys.spr(i))->x+((enemy*)guys.spr(i))->hxofs+(((enemy*)guys.spr(i))->hit_width/2)-8;
15373 ((item*)(s))->y = ((enemy*)guys.spr(i))->y+((enemy*)guys.spr(i))->hyofs+(((enemy*)guys.spr(i))->hit_height/2)-10;
15374 ((item*)(s))->z = ((enemy*)guys.spr(i))->z;
15375 }
15376 else
15377 {
15378 if(((enemy*)guys.spr(i))->extend >= 3)
15379 {
15380 ((item*)(s))->x = ((enemy*)guys.spr(i))->x+(((enemy*)guys.spr(i))->txsz-1)*8;
15381 ((item*)(s))->y = ((enemy*)guys.spr(i))->y-2+(((enemy*)guys.spr(i))->tysz-1)*8;
15382 ((item*)(s))->z = ((enemy*)guys.spr(i))->z;
15383 }
15384 else
15385 {
15386 ((item*)(s))->x = ((enemy*)guys.spr(i))->x;
15387 ((item*)(s))->y = ((enemy*)guys.spr(i))->y - 2;
15388 ((item*)(s))->z = ((enemy*)guys.spr(i))->z;
15389 }
15390 }
15391 }
15392 else
15393 {
15394 ((item*)(s))->x = ((enemy*)guys.spr(i))->x;
15395 ((item*)(s))->y = ((enemy*)guys.spr(i))->y - 2;
15396 ((item*)(s))->z = ((enemy*)guys.spr(i))->z;
15397 }
15398 break;
15399 }
15400 }
15401 }
15402
15403 if(more_carried_items()<=1) // 1 includes this own item.
15404 {
15405 hasitem &= ~2;
15406 }
15407 }
15408
15409 787 ((item*)(s))->pickup=value/10000;
15410 787 }
15411
15412 1181 break;
15413
15414 case ITEMMISCD:
15415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3013 times.
3013 if(0!=(s=checkItem(ri->itemref)))
15416 {
15417 3013 int32_t a = vbound(ri->d[rINDEX]/10000,0,31);
15418 3013 (((item*)(s))->miscellaneous[a])=value;
15419 3013 }
15420
15421 3013 break;
15422 case ITEMFALLCLK:
15423 if(0!=(s=checkItem(ri->itemref)))
15424 {
15425 if(((item*)(s))->fallclk != 0 && value == 0)
15426 {
15427 ((item*)(s))->cs = ((item*)(s))->old_cset;
15428 ((item*)(s))->tile = ((item*)(s))->o_tile;
15429 }
15430 else if(((item*)(s))->fallclk == 0 && value != 0) ((item*)(s))->old_cset = ((item*)(s))->cs;
15431 ((item*)(s))->fallclk = vbound(value/10000,0,70);
15432 }
15433 break;
15434 case ITEMFALLCMB:
15435 if(0!=(s=checkItem(ri->itemref)))
15436 {
15437 ((item*)(s))->fallCombo = vbound(value/10000,0,MAXCOMBOS-1);
15438 }
15439 break;
15440 case ITEMDROWNCLK:
15441 if(0!=(s=checkItem(ri->itemref)))
15442 {
15443 if(((item*)(s))->drownclk != 0 && value == 0)
15444 {
15445 ((item*)(s))->cs = ((item*)(s))->old_cset;
15446 ((item*)(s))->tile = ((item*)(s))->o_tile;
15447 }
15448 else if(((item*)(s))->drownclk == 0 && value != 0) ((item*)(s))->old_cset = ((item*)(s))->cs;
15449 ((item*)(s))->drownclk = vbound(value/10000,0,70);
15450 }
15451 break;
15452 case ITEMDROWNCMB:
15453 if(0!=(s=checkItem(ri->itemref)))
15454 {
15455 ((item*)(s))->drownCombo = vbound(value/10000,0,MAXCOMBOS-1);
15456 }
15457 break;
15458 case ITEMFAKEZ:
15459 if(0!=(s=checkItem(ri->itemref)))
15460 {
15461 (s->fakez)=(zfix)(value/10000);
15462
15463 if(s->fakez < 0)
15464 s->fakez = 0;
15465 }
15466
15467 break;
15468
15469 case ITEMMOVEFLAGS:
15470 {
15471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68 times.
68 if(0!=(s=checkItem(ri->itemref)))
15472 {
15473 68 int32_t indx = ri->d[rINDEX]/10000;
15474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68 times.
68 if(BC::checkBounds(indx, 0, 10, "itemsprite->MoveFlags[]") == SH::_NoError)
15475 {
15476 //All bits, in order, of a single byte; just use bitwise
15477 68 int32_t bit = 1<<indx;
15478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68 times.
68 if(value)
15479 ((item*)(s))->moveflags |= bit;
15480 else
15481 68 ((item*)(s))->moveflags &= ~bit;
15482 68 }
15483 68 }
15484 68 break;
15485 }
15486
15487 case ITEMGLOWRAD:
15488 if(0!=(s=checkItem(ri->itemref)))
15489 {
15490 ((item*)(s))->glowRad = vbound(value/10000,0,255);
15491 }
15492 break;
15493
15494 case ITEMGLOWSHP:
15495 if(0!=(s=checkItem(ri->itemref)))
15496 {
15497 ((item*)(s))->glowShape = vbound(value/10000,0,255);
15498 }
15499 break;
15500
15501 case ITEMDIR:
15502 if(0!=(s=checkItem(ri->itemref)))
15503 {
15504 ((item*)(s))->dir=(value/10000);
15505 }
15506 break;
15507
15508 case ITEMENGINEANIMATE:
15509 if(0!=(s=checkItem(ri->itemref)))
15510 {
15511 ((item*)(s))->do_animation=(value ? 1 : 0);
15512 }
15513 break;
15514
15515 case ITEMSHADOWSPR:
15516 if(0!=(s=checkItem(ri->itemref)))
15517 {
15518 ((item*)(s))->spr_shadow=vbound(value/10000,0,255);
15519 }
15520 break;
15521 case ITEMDROPPEDBY:
15522 if(0!=(s=checkItem(ri->itemref)))
15523 {
15524 ((item*)(s))->from_dropset=vbound(value/10000,-1,255);
15525 }
15526 break;
15527 case ITMSWHOOKED:
15528 break; //read-only
15529 case ITEMFORCEGRAB:
15530 if(0!=(s=checkItem(ri->itemref)))
15531 {
15532 ((item*)(s))->set_forcegrab(value!=0);
15533 }
15534 break;
15535
15536 ///----------------------------------------------------------------------------------------------------//
15537 //Itemdata Variables
15538 //not mine, but let;s guard some of them all the same -Z
15539 //item class
15540 case IDATAFAMILY:
15541 if(unsigned(ri->idata) >= MAXITEMS)
15542 {
15543 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15544 break;
15545 }
15546 (itemsbuf[ri->idata].family)=vbound(value/10000,0, 254);
15547 flushItemCache();
15548 break;
15549
15550 case IDATAUSEWPN:
15551 if(unsigned(ri->idata) >= MAXITEMS)
15552 {
15553 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15554 break;
15555 }
15556 (itemsbuf[ri->idata].useweapon)=vbound(value/10000, 0, 255);
15557 break;
15558 case IDATAUSEDEF:
15559 if(unsigned(ri->idata) >= MAXITEMS)
15560 {
15561 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15562 break;
15563 }
15564 (itemsbuf[ri->idata].usedefence)=vbound(value/10000, 0, 255);
15565 break;
15566 case IDATAWRANGE:
15567 if(unsigned(ri->idata) >= MAXITEMS)
15568 {
15569 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15570 break;
15571 }
15572 (itemsbuf[ri->idata].weaprange)=vbound(value/10000, 0, 255);
15573 break;
15574 case IDATAMAGICTIMER:
15575 if(unsigned(ri->idata) >= MAXITEMS)
15576 {
15577 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15578 break;
15579 }
15580 (itemsbuf[ri->idata].magiccosttimer[0])=vbound(value/10000, 0, 214747);
15581 break;
15582 case IDATAMAGICTIMER2:
15583 if(unsigned(ri->idata) >= MAXITEMS)
15584 {
15585 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15586 break;
15587 }
15588 (itemsbuf[ri->idata].magiccosttimer[1])=vbound(value/10000, 0, 214747);
15589 break;
15590 case IDATADURATION:
15591 if(unsigned(ri->idata) >= MAXITEMS)
15592 {
15593 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15594 break;
15595 }
15596 (itemsbuf[ri->idata].weapduration)=vbound(value/10000, 0, 255);
15597 break;
15598
15599 case IDATADUPLICATES:
15600 if(unsigned(ri->idata) >= MAXITEMS)
15601 {
15602 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15603 break;
15604 }
15605 (itemsbuf[ri->idata].duplicates)=vbound(value/10000, 0, 255);
15606 break;
15607 case IDATADRAWLAYER:
15608 if(unsigned(ri->idata) >= MAXITEMS)
15609 {
15610 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15611 break;
15612 }
15613 (itemsbuf[ri->idata].drawlayer)=vbound(value/10000, 0, 7);
15614 break;
15615 case IDATACOLLECTFLAGS:
15616 if(unsigned(ri->idata) >= MAXITEMS)
15617 {
15618 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15619 break;
15620 }
15621 //int32_t a = ri->d[rINDEX] / 10000;
15622 (itemsbuf[ri->idata].collectflags)=vbound(value/10000, 0, 214747);
15623 break;
15624 case IDATAWEAPONSCRIPT:
15625 if(unsigned(ri->idata) >= MAXITEMS)
15626 {
15627 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15628 break;
15629 }
15630 (itemsbuf[ri->idata].weaponscript)=vbound(value/10000, 0, 255);
15631 break;
15632 case IDATAMISCD:
15633 {
15634 if(unsigned(ri->idata) >= MAXITEMS)
15635 {
15636 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15637 break;
15638 }
15639 int32_t a = vbound((ri->d[rINDEX] / 10000),0,31);
15640 (itemsbuf[ri->idata].wpn_misc_d[a])=(value/10000);
15641 }
15642 break;
15643 case IDATAWPNINITD:
15644 {
15645 if(unsigned(ri->idata) >= MAXITEMS)
15646 {
15647 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15648 break;
15649 }
15650 int32_t a = vbound((ri->d[rINDEX] / 10000),0,7);
15651 (itemsbuf[ri->idata].weap_initiald[a])=(value);
15652 }
15653 break;
15654 case IDATAWEAPHXOFS:
15655 if(unsigned(ri->idata) >= MAXITEMS)
15656 {
15657 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15658 break;
15659 }
15660 (itemsbuf[ri->idata].weap_hxofs)=(value/10000);
15661 break;
15662 case IDATAWEAPHYOFS:
15663 if(unsigned(ri->idata) >= MAXITEMS)
15664 {
15665 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15666 break;
15667 }
15668 (itemsbuf[ri->idata].weap_hyofs)=(value/10000);
15669 break;
15670 case IDATAWEAPHXSZ:
15671 if(unsigned(ri->idata) >= MAXITEMS)
15672 {
15673 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15674 break;
15675 }
15676 (itemsbuf[ri->idata].weap_hxsz)=(value/10000);
15677 break;
15678 case IDATAWEAPHYSZ:
15679 if(unsigned(ri->idata) >= MAXITEMS)
15680 {
15681 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15682 break;
15683 }
15684 (itemsbuf[ri->idata].weap_hysz)=(value/10000);
15685 break;
15686 case IDATAWEAPHZSZ:
15687 if(unsigned(ri->idata) >= MAXITEMS)
15688 {
15689 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15690 break;
15691 }
15692 (itemsbuf[ri->idata].weap_hzsz)=(value/10000);
15693 break;
15694 case IDATAWEAPXOFS:
15695 if(unsigned(ri->idata) >= MAXITEMS)
15696 {
15697 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15698 break;
15699 }
15700 (itemsbuf[ri->idata].weap_xofs)=(value/10000);
15701 break;
15702 case IDATAWEAPYOFS:
15703 if(unsigned(ri->idata) >= MAXITEMS)
15704 {
15705 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15706 break;
15707 }
15708 (itemsbuf[ri->idata].weap_yofs)=(value/10000);
15709 break;
15710
15711
15712 case IDATAHXOFS:
15713 if(unsigned(ri->idata) >= MAXITEMS)
15714 {
15715 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15716 break;
15717 }
15718 (itemsbuf[ri->idata].hxofs)=(value/10000);
15719 break;
15720 case IDATAHYOFS:
15721 if(unsigned(ri->idata) >= MAXITEMS)
15722 {
15723 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15724 break;
15725 }
15726 (itemsbuf[ri->idata].hyofs)=(value/10000);
15727 break;
15728 case IDATAHXSZ:
15729 if(unsigned(ri->idata) >= MAXITEMS)
15730 {
15731 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15732 break;
15733 }
15734 (itemsbuf[ri->idata].hxsz)=(value/10000);
15735 break;
15736 case IDATAHYSZ:
15737 if(unsigned(ri->idata) >= MAXITEMS)
15738 {
15739 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15740 break;
15741 }
15742 (itemsbuf[ri->idata].hysz)=(value/10000);
15743 break;
15744 case IDATAHZSZ:
15745 if(unsigned(ri->idata) >= MAXITEMS)
15746 {
15747 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15748 break;
15749 }
15750 (itemsbuf[ri->idata].hzsz)=(value/10000);
15751 break;
15752 case IDATADXOFS:
15753 if(unsigned(ri->idata) >= MAXITEMS)
15754 {
15755 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15756 break;
15757 }
15758 (itemsbuf[ri->idata].xofs)=(value/10000);
15759 break;
15760 case IDATADYOFS:
15761 if(unsigned(ri->idata) >= MAXITEMS)
15762 {
15763 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15764 break;
15765 }
15766 (itemsbuf[ri->idata].yofs)=(value/10000);
15767 break;
15768 case IDATATILEW:
15769 if(unsigned(ri->idata) >= MAXITEMS)
15770 {
15771 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15772 break;
15773 }
15774 (itemsbuf[ri->idata].tilew)=(value/10000);
15775 break;
15776 case IDATATILEH:
15777 if(unsigned(ri->idata) >= MAXITEMS)
15778 {
15779 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15780 break;
15781 }
15782 (itemsbuf[ri->idata].tileh)=(value/10000);
15783 break;
15784 case IDATAPICKUP:
15785 if(unsigned(ri->idata) >= MAXITEMS)
15786 {
15787 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15788 break;
15789 }
15790 (itemsbuf[ri->idata].pickup)=(value/10000);
15791 break;
15792 case IDATAOVERRIDEFL:
15793 if(unsigned(ri->idata) >= MAXITEMS)
15794 {
15795 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15796 break;
15797 }
15798 (itemsbuf[ri->idata].overrideFLAGS)=(value/10000);
15799 break;
15800
15801 case IDATATILEWWEAP:
15802 if(unsigned(ri->idata) >= MAXITEMS)
15803 {
15804 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15805 break;
15806 }
15807 (itemsbuf[ri->idata].weap_tilew)=(value/10000);
15808 break;
15809 case IDATATILEHWEAP:
15810 if(unsigned(ri->idata) >= MAXITEMS)
15811 {
15812 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15813 break;
15814 }
15815 (itemsbuf[ri->idata].weap_tileh)=(value/10000);
15816 break;
15817 case IDATAOVERRIDEFLWEAP:
15818 if(unsigned(ri->idata) >= MAXITEMS)
15819 {
15820 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15821 break;
15822 }
15823 (itemsbuf[ri->idata].weapoverrideFLAGS)=(value/10000);
15824 break;
15825
15826 case IDATAUSEMVT:
15827 {
15828 if(unsigned(ri->idata) >= MAXITEMS)
15829 {
15830 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15831 break;
15832 }
15833 int32_t a = vbound((ri->d[rINDEX] / 10000),0,(ITEM_MOVEMENT_PATTERNS-1));
15834 (itemsbuf[ri->idata].weap_pattern[a])=vbound(value/10000, 0, 255);
15835 break;
15836 }
15837
15838 case IDATALEVEL:
15839 if(unsigned(ri->idata) >= MAXITEMS)
15840 {
15841 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15842 break;
15843 }
15844 (itemsbuf[ri->idata].fam_type)=vbound(value/10000, 0, 512);
15845 flushItemCache();
15846 break;
15847 case IDATAKEEP:
15848 item_flag(ITEM_GAMEDATA, value);
15849 break;
15850 case IDATAAMOUNT:
15851 {
15852 if(unsigned(ri->idata) >= MAXITEMS)
15853 {
15854 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15855 break;
15856 }
15857 int32_t v = vbound(value/10000, -9999, 16383);
15858 itemsbuf[ri->idata].amount &= 0x8000;
15859 itemsbuf[ri->idata].amount |= (abs(v)&0x3FFF)|(v<0?0x4000:0);
15860 break;
15861 }
15862 case IDATAGRADUAL:
15863 {
15864 if(unsigned(ri->idata) >= MAXITEMS)
15865 {
15866 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15867 break;
15868 }
15869 SETFLAG(itemsbuf[ri->idata].amount, 0x8000, value!=0);
15870 break;
15871 }
15872 case IDATACONSTSCRIPT:
15873 item_flag(ITEM_PASSIVESCRIPT, value);
15874 break;
15875 case IDATASSWIMDISABLED:
15876 item_flag(ITEM_SIDESWIM_DISABLED, value);
15877 break;
15878 case IDATABUNNYABLE:
15879 item_flag(ITEM_BUNNY_ENABLED, value);
15880 break;
15881 case IDATAJINXIMMUNE:
15882 item_flag(ITEM_JINX_IMMUNE, value);
15883 break;
15884 case IDATAJINXSWAP:
15885 item_flag(ITEM_FLIP_JINX, value);
15886 break;
15887 case IDATASETMAX:
15888 if(unsigned(ri->idata) >= MAXITEMS)
15889 {
15890 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15891 break;
15892 }
15893 (itemsbuf[ri->idata].setmax)=value/10000;
15894 break;
15895
15896 case IDATAMAX:
15897 if(unsigned(ri->idata) >= MAXITEMS)
15898 {
15899 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15900 break;
15901 }
15902 (itemsbuf[ri->idata].max)=value/10000;
15903 break;
15904
15905 case IDATAPOWER:
15906 if(unsigned(ri->idata) >= MAXITEMS)
15907 {
15908 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15909 break;
15910 }
15911 (itemsbuf[ri->idata].power)=value/10000;
15912 break;
15913
15914 case IDATACOUNTER:
15915 if(unsigned(ri->idata) >= MAXITEMS)
15916 {
15917 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15918 break;
15919 }
15920 (itemsbuf[ri->idata].count)=vbound(value/10000,0,31);
15921 break;
15922
15923 case IDATAPSOUND:
15924 if(unsigned(ri->idata) >= MAXITEMS)
15925 {
15926 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15927 break;
15928 }
15929 (itemsbuf[ri->idata].playsound)=vbound(value/10000, 0, 255);
15930 break;
15931
15932 case IDATAUSESOUND:
15933 if(unsigned(ri->idata) >= MAXITEMS)
15934 {
15935 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15936 break;
15937 }
15938 (itemsbuf[ri->idata].usesound)=vbound(value/10000, 0, 255);
15939 break;
15940
15941 case IDATAUSESOUND2:
15942 if(unsigned(ri->idata) >= MAXITEMS)
15943 {
15944 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15945 break;
15946 }
15947 (itemsbuf[ri->idata].usesound2)=vbound(value/10000, 0, 255);
15948 break;
15949
15950 //2.54
15951 //My additions begin here. -Z
15952 //Stack item to gain next level
15953 case IDATACOMBINE:
15954 item_flag(ITEM_COMBINE, value);
15955 break;
15956 //using a level of an item downgrades to a lower one
15957 case IDATADOWNGRADE:
15958 item_flag(ITEM_DOWNGRADE, value);
15959 break;
15960 //Only validate the cost, don't charge it
15961 case IDATAVALIDATE:
15962 item_flag(ITEM_VALIDATEONLY, value);
15963 break;
15964 case IDATAVALIDATE2:
15965 item_flag(ITEM_VALIDATEONLY2, value);
15966 break;
15967
15968 //Flags[5]
15969 case IDATAFLAGS:
15970 {
15971 if(unsigned(ri->idata) >= MAXITEMS)
15972 {
15973 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
15974 break;
15975 }
15976 int32_t index = ri->d[rINDEX]/10000;
15977 switch(index)
15978 {
15979 case 0:
15980 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG1, value);
15981 break;
15982 case 1:
15983 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG2, value);
15984 break;
15985 case 2:
15986 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG3, value);
15987 break;
15988 case 3:
15989 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG4, value);
15990 break;
15991 case 4:
15992 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG5, value);
15993 break;
15994 case 5:
15995 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG6, value);
15996 break;
15997 case 6:
15998 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG7, value);
15999 break;
16000 case 7:
16001 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG8, value);
16002 break;
16003 case 8:
16004 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG9, value);
16005 break;
16006 case 9:
16007 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG10, value);
16008 break;
16009 case 10:
16010 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG11, value);
16011 break;
16012 case 11:
16013 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG12, value);
16014 break;
16015 case 12:
16016 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG13, value);
16017 break;
16018 case 13:
16019 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG14, value);
16020 break;
16021 case 14:
16022 SETFLAG(itemsbuf[ri->idata].flags, ITEM_FLAG15, value);
16023 break;
16024 case 15:
16025 SETFLAG(itemsbuf[ri->idata].flags, ITEM_PASSIVESCRIPT, value);
16026 break;
16027 }
16028
16029 break;
16030 }
16031 //Keep Old in editor
16032 case IDATAKEEPOLD:
16033 item_flag(ITEM_KEEPOLD, value);
16034 break;
16035 //Ruppes for magic
16036 case IDATARUPEECOST:
16037 item_flag(ITEM_RUPEE_MAGIC, value);
16038 break;
16039 //can be eaten
16040 case IDATAEDIBLE:
16041 item_flag(ITEM_EDIBLE, value);
16042 break;
16043 //Unused at this time
16044 case IDATAFLAGUNUSED:
16045 item_flag(ITEM_UNUSED, value);
16046 break;
16047 //gain lower level items
16048 case IDATAGAINLOWER:
16049 item_flag(ITEM_GAINOLD, value);
16050 break;
16051 //Set the action script
16052 case IDATASCRIPT:
16053 if(unsigned(ri->idata) >= MAXITEMS)
16054 {
16055 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
16056 break;
16057 }
16058 FFScript::deallocateAllArrays(ScriptType::Item, ri->idata);
16059 itemsbuf[ri->idata].script=vbound(value/10000,0,255);
16060 break;
16061 case IDATASPRSCRIPT:
16062 if(unsigned(ri->idata) >= MAXITEMS)
16063 {
16064 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
16065 break;
16066 }
16067 itemsbuf[ri->idata].sprite_script=vbound(value/10000,0,255);
16068 break;
16069
16070 /*
16071 case ITEMMISCD:
16072 if(0!=(s=checkItem(ri->itemref)))
16073 {
16074 int32_t a = vbound(ri->d[rINDEX]/10000,0,31);
16075 (((item*)(s))->miscellaneous[a])=value;
16076 }
16077
16078 break;*/
16079 //Attributes[10]
16080 case IDATAATTRIB: {
16081 if(unsigned(ri->idata) >= MAXITEMS)
16082 {
16083 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
16084 break;
16085 }
16086 int32_t index = vbound(ri->d[rINDEX]/10000,0,9);
16087 switch(index)
16088 {
16089 case 0:
16090 itemsbuf[ri->idata].misc1=value/10000;
16091 break;
16092 case 1:
16093 itemsbuf[ri->idata].misc2=value/10000; break;
16094 case 2:
16095 itemsbuf[ri->idata].misc3=value/10000; break;
16096 case 3:
16097 itemsbuf[ri->idata].misc4=value/10000; break;
16098 case 4:
16099 itemsbuf[ri->idata].misc5=value/10000; break;
16100 case 5:
16101 itemsbuf[ri->idata].misc6=value/10000; break;
16102 case 6:
16103 itemsbuf[ri->idata].misc7=value/10000; break;
16104 case 7:
16105 itemsbuf[ri->idata].misc8=value/10000; break;
16106 case 8:
16107 itemsbuf[ri->idata].misc9=value/10000; break;
16108 case 9:
16109 itemsbuf[ri->idata].misc10=value/10000; break;
16110
16111 default:
16112 break;
16113 }
16114
16115 break;
16116 }
16117 //SpriteSprites[10]
16118 case IDATASPRITE:
16119 {
16120 if(unsigned(ri->idata) >= MAXITEMS)
16121 {
16122 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
16123 break;
16124 }
16125 int32_t index = vbound(ri->d[rINDEX]/10000,0,9);
16126 switch(index)
16127 {
16128 case 0:
16129 itemsbuf[ri->idata].wpn=vbound(value/10000, 0, 255);
16130 break;
16131 case 1:
16132 itemsbuf[ri->idata].wpn2=vbound(value/10000, 0, 255); break;
16133 case 2:
16134 itemsbuf[ri->idata].wpn3=vbound(value/10000, 0, 255); break;
16135 case 3:
16136 itemsbuf[ri->idata].wpn4=vbound(value/10000, 0, 255); break;
16137 case 4:
16138 itemsbuf[ri->idata].wpn5=vbound(value/10000, 0, 255); break;
16139 case 5:
16140 itemsbuf[ri->idata].wpn6=vbound(value/10000, 0, 255); break;
16141 case 6:
16142 itemsbuf[ri->idata].wpn7=vbound(value/10000, 0, 255); break;
16143 case 7:
16144 itemsbuf[ri->idata].wpn8=vbound(value/10000, 0, 255); break;
16145 case 8:
16146 itemsbuf[ri->idata].wpn9=vbound(value/10000, 0, 255); break;
16147 case 9:
16148 itemsbuf[ri->idata].wpn10=vbound(value/10000, 0, 255); break;
16149
16150 default:
16151 break;
16152 }
16153
16154 break;
16155 }
16156 //Hero tile modifier.
16157 case IDATALTM:
16158 if(unsigned(ri->idata) >= MAXITEMS)
16159 {
16160 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
16161 break;
16162 }
16163 itemsbuf[ri->idata].ltm=value/10000;
16164 break;
16165 //Pickup script
16166 case IDATAPSCRIPT:
16167 {
16168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2760 times.
2760 if(unsigned(ri->idata) >= MAXITEMS)
16169 {
16170 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
16171 break;
16172 }
16173 //Need to get collect script ref, not standard idata ref!
16174
1/2
✓ Branch 0 taken 2760 times.
✗ Branch 1 not taken.
2760 const int32_t new_ref = ri->idata!=0 ? -(ri->idata) : COLLECT_SCRIPT_ITEM_ZERO;
16175 2760 FFScript::deallocateAllArrays(ScriptType::Item,new_ref);
16176 2760 itemsbuf[ri->idata].collect_script=vbound(value/10000, 0, 255);
16177 2760 break;
16178 }
16179 //pickup string
16180 case IDATAPSTRING:
16181 if(unsigned(ri->idata) >= MAXITEMS)
16182 {
16183 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
16184 break;
16185 }
16186 itemsbuf[ri->idata].pstring=vbound(value/10000, 1, 255);
16187 break;
16188 case IDATAPFLAGS:
16189 if(unsigned(ri->idata) >= MAXITEMS)
16190 {
16191 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
16192 break;
16193 }
16194 itemsbuf[ri->idata].pickup_string_flags=vbound(value/10000, 0, 214748);
16195 break;
16196 //magic cost
16197 case IDATAMAGCOST:
16198 if(unsigned(ri->idata) >= MAXITEMS)
16199 {
16200 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
16201 break;
16202 }
16203 itemsbuf[ri->idata].cost_amount[0]=vbound(value/10000,32767,-32768);
16204 break;
16205 case IDATACOST2:
16206 if(unsigned(ri->idata) >= MAXITEMS)
16207 {
16208 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
16209 break;
16210 }
16211 itemsbuf[ri->idata].cost_amount[1]=vbound(value/10000,32767,-32768);
16212 break;
16213 //cost counter ref
16214 case IDATACOSTCOUNTER:
16215 if(unsigned(ri->idata) >= MAXITEMS)
16216 {
16217 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
16218 break;
16219 }
16220 itemsbuf[ri->idata].cost_counter[0]=(vbound(value/10000,-1,32));
16221 break;
16222 case IDATACOSTCOUNTER2:
16223 if(unsigned(ri->idata) >= MAXITEMS)
16224 {
16225 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
16226 break;
16227 }
16228 itemsbuf[ri->idata].cost_counter[1]=(vbound(value/10000,-1,32));
16229 break;
16230 //min hearts to pick up
16231 case IDATAMINHEARTS:
16232 if(unsigned(ri->idata) >= MAXITEMS)
16233 {
16234 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
16235 break;
16236 }
16237 itemsbuf[ri->idata].pickup_hearts=vbound(value/10000, 0, 214748);
16238 break;
16239 //item tile
16240 case IDATATILE:
16241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if(unsigned(ri->idata) >= MAXITEMS)
16242 {
16243 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
16244 break;
16245 }
16246 70 itemsbuf[ri->idata].tile=vbound(value/10000, 0, 65519);
16247 70 break;
16248 //flash
16249 case IDATAMISC:
16250 if(unsigned(ri->idata) >= MAXITEMS)
16251 {
16252 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
16253 break;
16254 }
16255 itemsbuf[ri->idata].misc_flags=value/10000;
16256 break;
16257 //cset
16258 case IDATACSET:
16259 if(unsigned(ri->idata) >= MAXITEMS)
16260 {
16261 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
16262 break;
16263 }
16264 itemsbuf[ri->idata].csets=vbound(value/10000,0,13);
16265 break;
16266 /*
16267 case IDATAFRAME:
16268 itemsbuf[ri->idata].frame=value/10000;
16269 break;
16270 */
16271 //A.Frames
16272 case IDATAFRAMES:
16273 if(unsigned(ri->idata) >= MAXITEMS)
16274 {
16275 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
16276 break;
16277 }
16278 (itemsbuf[ri->idata].frames)=vbound(value/10000, 0, 214748);
16279 break;
16280 //A.speed
16281 case IDATAASPEED:
16282 if(unsigned(ri->idata) >= MAXITEMS)
16283 {
16284 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
16285 break;
16286 }
16287 itemsbuf[ri->idata].speed=vbound(value/10000, 0, 214748);
16288 break;
16289 //Anim delay
16290 case IDATADELAY:
16291 if(unsigned(ri->idata) >= MAXITEMS)
16292 {
16293 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
16294 break;
16295 }
16296 itemsbuf[ri->idata].delay=vbound(value/10000, 0, 214748);
16297 break;
16298
16299 //not one of mine.
16300 case IDATAINITDD:
16301 {
16302 int32_t a = ri->d[rINDEX] / 10000;
16303 if(unsigned(ri->idata) >= MAXITEMS)
16304 {
16305 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
16306 break;
16307 }
16308
16309 if(BC::checkBounds(a, 0, 7, "itemdata->InitD") == SH::_NoError)
16310 itemsbuf[ri->idata].initiald[a] = value;
16311 }
16312 break;
16313
16314 ///----------------------------------------------------------------------------------------------------//
16315 //LWeapon Variables
16316
16317 case LWPNSCALE:
16318 if ( get_qr(qr_OLDSPRITEDRAWS) )
16319 {
16320 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
16321 "lweapon->Scale");
16322 break;
16323 }
16324 if(0!=(s=checkLWpn(ri->lwpn,"Scale")))
16325 ((weapon*)s)->scale=(zfix)(value/100.0);
16326
16327 break;
16328
16329 case LWPNX:
16330
2/2
✓ Branch 0 taken 6717 times.
✓ Branch 1 taken 187023 times.
193740 if(0!=(s=checkLWpn(ri->lwpn,"X")))
16331
2/2
✓ Branch 0 taken 61572 times.
✓ Branch 1 taken 125451 times.
187023 ((weapon*)s)->x=get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000);
16332 193740 break;
16333
16334 case SPRITEMAXLWPN:
16335 {
16336 //No bounds check, as this is a universal function and works from NULL pointers!
16337 Lwpns.setMax(vbound((value/10000),1,MAX_LWPN_SPRITES));
16338 break;
16339 }
16340
16341 case LWPNY:
16342
2/2
✓ Branch 0 taken 6717 times.
✓ Branch 1 taken 187016 times.
193733 if(0!=(s=checkLWpn(ri->lwpn,"Y")))
16343
2/2
✓ Branch 0 taken 61572 times.
✓ Branch 1 taken 125444 times.
187016 ((weapon*)s)->y=get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000);
16344
16345 193733 break;
16346
16347 case LWPNZ:
16348 if(0!=(s=checkLWpn(ri->lwpn,"Z")))
16349 {
16350 ((weapon*)s)->z=get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000);
16351 if(((weapon*)s)->z < 0) ((weapon*)s)->z = zfix(0);
16352 }
16353
16354 break;
16355
16356 case LWPNJUMP:
16357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180 times.
180 if(0!=(s=checkLWpn(ri->lwpn,"Jump")))
16358 180 ((weapon*)s)->fall=zslongToFix(value)*-100;
16359
16360 180 break;
16361
16362 case LWPNFAKEJUMP:
16363 if(0!=(s=checkLWpn(ri->lwpn,"FakeJump")))
16364 ((weapon*)s)->fakefall=zslongToFix(value)*-100;
16365
16366 break;
16367
16368 case LWPNDIR:
16369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 65038 times.
65038 if(0!=(s=checkLWpn(ri->lwpn,"Dir")))
16370 {
16371 65038 ((weapon*)s)->dir=(value/10000);
16372 65038 ((weapon*)s)->doAutoRotate(true);
16373 65038 }
16374
16375 65038 break;
16376
16377 case LWPNSPECIAL:
16378 if(0!=(s=checkLWpn(ri->lwpn,"Special")))
16379 ((weapon*)s)->specialinfo=(value/10000);
16380
16381 break;
16382
16383 case LWPNGRAVITY:
16384 if(0!=(s=checkLWpn(ri->lwpn,"Gravity")))
16385 {
16386 if(value)
16387 ((weapon*)s)->moveflags |= FLAG_OBEYS_GRAV;
16388 else
16389 ((weapon*)s)->moveflags &= ~FLAG_OBEYS_GRAV;
16390 }
16391 break;
16392
16393 case LWPNSTEP:
16394
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8276 times.
8276 if(0!=(s=checkLWpn(ri->lwpn,"Step")))
16395 {
16396 // fp math is bad for replay, so always ignore this QR when replay is active.
16397 // TODO: can we just delete this QR? Would it actually break anything? For now,
16398 // just disable for replay and wait for more tests to be played with this QR
16399 // ignored.
16400
3/4
✓ Branch 0 taken 7031 times.
✓ Branch 1 taken 1245 times.
✓ Branch 2 taken 7031 times.
✗ Branch 3 not taken.
8276 if ( get_qr(qr_STEP_IS_FLOAT) || replay_is_active() )
16401 {
16402 8276 ((weapon*)s)->step= zslongToFix(value / 100);
16403 8276 }
16404 else
16405 {
16406 //old, buggy code replication, round two: Go! -Z
16407 //zfix val = zslongToFix(value);
16408 //val.doFloor();
16409 //((weapon*)s)->step = ((val / 100.0).getFloat());
16410
16411 //old, buggy code replication, round THREE: Go! -Z
16412 ((weapon*)s)->step = ((value/10000)/100.0);
16413 }
16414
16415 8276 }
16416
16417 8276 break;
16418
16419 case LWPNANGLE:
16420
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1469 times.
1469 if(0!=(s=checkLWpn(ri->lwpn,"Angle")))
16421 {
16422 1469 ((weapon*)s)->angle=(double)(value/10000.0);
16423 1469 ((weapon*)(s))->doAutoRotate();
16424 1469 }
16425
16426 1469 break;
16427
16428 case LWPNDEGANGLE:
16429 if(0!=(s=checkLWpn(ri->lwpn,"DegAngle")))
16430 {
16431 double rangle = (value / 10000.0) * (PI / 180.0);
16432 ((weapon*)s)->angle=(double)(rangle);
16433 ((weapon*)(s))->doAutoRotate();
16434 }
16435
16436 break;
16437
16438 case LWPNVX:
16439 if(0!=(s=checkLWpn(ri->lwpn,"Vx")))
16440 {
16441 double vy;
16442 double vx = (value / 10000.0);
16443 if (((weapon*)(s))->angular)
16444 vy = zc::math::Sin(((weapon*)s)->angle)*((weapon*)s)->step;
16445 else
16446 {
16447 switch(NORMAL_DIR(((weapon*)(s))->dir))
16448 {
16449 case l_up:
16450 case r_up:
16451 case up:
16452 vy = -1.0*((weapon*)s)->step;
16453 break;
16454 case l_down:
16455 case r_down:
16456 case down:
16457 vy = ((weapon*)s)->step;
16458 break;
16459
16460 default:
16461 vy = 0;
16462 break;
16463 }
16464 }
16465 ((weapon*)s)->angular = true;
16466 ((weapon*)s)->angle=atan2(vy, vx);
16467 ((weapon*)s)->step=FFCore.Distance(0, 0, vx, vy)/10000.0;
16468 ((weapon*)(s))->doAutoRotate();
16469 }
16470
16471 break;
16472
16473 case LWPNVY:
16474 if(0!=(s=checkLWpn(ri->lwpn,"Vy")))
16475 {
16476 double vx;
16477 double vy = (value / 10000.0);
16478 if (((weapon*)(s))->angular)
16479 vx = zc::math::Cos(((weapon*)s)->angle)*((weapon*)s)->step;
16480 else
16481 {
16482 switch(NORMAL_DIR(((weapon*)(s))->dir))
16483 {
16484 case l_up:
16485 case l_down:
16486 case left:
16487 vx = -1.0*((weapon*)s)->step;
16488 break;
16489 case r_down:
16490 case r_up:
16491 case right:
16492 vx = ((weapon*)s)->step;
16493 break;
16494
16495 default:
16496 vx = 0;
16497 break;
16498 }
16499 }
16500 ((weapon*)s)->angular = true;
16501 ((weapon*)s)->angle=atan2(vy, vx);
16502 ((weapon*)s)->step=FFCore.Distance(0, 0, vx, vy)/10000.0;
16503 ((weapon*)(s))->doAutoRotate();
16504 }
16505
16506 break;
16507
16508 case LWPNANGULAR:
16509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1175 times.
1175 if(0!=(s=checkLWpn(ri->lwpn,"Angular")))
16510 {
16511 1175 ((weapon*)s)->angular=(value!=0);
16512 1175 ((weapon*)(s))->doAutoRotate(false, true);
16513 1175 }
16514
16515 1175 break;
16516
16517 case LWPNAUTOROTATE:
16518 if(0!=(s=checkLWpn(ri->lwpn,"AutoRotate")))
16519 {
16520 ((weapon*)s)->autorotate=(value!=0);
16521 ((weapon*)(s))->doAutoRotate(false, true);
16522 }
16523
16524 break;
16525
16526 case LWPNBEHIND:
16527 if(0!=(s=checkLWpn(ri->lwpn,"Behind")))
16528 ((weapon*)s)->behind=(value!=0);
16529
16530 break;
16531
16532 case LWPNDRAWTYPE:
16533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49 times.
49 if(0!=(s=checkLWpn(ri->lwpn,"DrawStyle")))
16534 49 ((weapon*)s)->drawstyle=(value/10000);
16535
16536 49 break;
16537
16538 case LWPNPOWER:
16539
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69347 times.
69347 if(0!=(s=checkLWpn(ri->lwpn,"Damage")))
16540 69347 ((weapon*)s)->power=(value/10000);
16541
16542 69347 break;
16543 /*
16544 case LWPNRANGE:
16545 if(0!=(s=checkLWpn(ri->lwpn,"Range")))
16546 ((weapon*)s)->scriptrange=vbound((value/10000),0,512); //Allow it to move off-screen. -Z
16547 break;
16548 */
16549 case LWPNDEAD:
16550
2/2
✓ Branch 0 taken 6717 times.
✓ Branch 1 taken 132457 times.
139174 if(0!=(s=checkLWpn(ri->lwpn,"DeadState")))
16551 {
16552 132457 auto dead = value/10000;
16553 132457 ((weapon*)s)->dead=dead;
16554
2/2
✓ Branch 0 taken 68348 times.
✓ Branch 1 taken 64109 times.
132457 if(dead != 0) ((weapon*)s)->weapon_dying_frame = false;
16555 132457 }
16556 139174 break;
16557
16558 case LWPNID:
16559 if(0!=(s=checkLWpn(ri->lwpn,"ID")))
16560 ((weapon*)s)->id=(value/10000);
16561
16562 break;
16563
16564 case LWPNTILE:
16565
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1853 times.
1853 if(0!=(s=checkLWpn(ri->lwpn,"Tile")))
16566 1853 ((weapon*)s)->tile=(value/10000);
16567
16568 1853 break;
16569
16570 case LWPNSCRIPTTILE:
16571 if(0!=(s=checkLWpn(ri->lwpn,"ScriptTile")))
16572 ((weapon*)s)->scripttile=vbound((value/10000),-1,NEWMAXTILES-1);
16573
16574 break;
16575
16576 case LWPNSCRIPTFLIP:
16577 if(0!=(s=checkLWpn(ri->lwpn,"ScriptFlip")))
16578 ((weapon*)s)->scriptflip=vbound((value/10000),-1,127);
16579
16580 break;
16581
16582 case LWPNCSET:
16583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2049 times.
2049 if(0!=(s=checkLWpn(ri->lwpn,"CSet")))
16584 2049 ((weapon*)s)->cs=(value/10000)&15;
16585
16586 2049 break;
16587
16588 case LWPNFLASHCSET:
16589 if(0!=(s=checkLWpn(ri->lwpn,"FlashCSet")))
16590 (((weapon*)s)->o_cset)|=(value/10000)<<4;
16591
16592 break;
16593
16594 case LWPNFRAMES:
16595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 404 times.
404 if(0!=(s=checkLWpn(ri->lwpn,"NumFrames")))
16596 404 ((weapon*)s)->frames=(value/10000);
16597
16598 404 break;
16599
16600 case LWPNFRAME:
16601 if(0!=(s=checkLWpn(ri->lwpn,"Frame")))
16602 ((weapon*)s)->aframe=(value/10000);
16603
16604 break;
16605
16606 case LWPNASPEED:
16607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if(0!=(s=checkLWpn(ri->lwpn,"ASpeed")))
16608 457 ((weapon*)s)->o_speed=(value/10000);
16609
16610 457 break;
16611
16612 case LWPNFLASH:
16613 if(0!=(s=checkLWpn(ri->lwpn,"Flash")))
16614 ((weapon*)s)->flash=(value/10000);
16615
16616 break;
16617
16618 case LWPNFLIP:
16619
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 683 times.
683 if(0!=(s=checkLWpn(ri->lwpn,"Flip")))
16620 683 ((weapon*)s)->flip=(value/10000);
16621
16622 683 break;
16623
16624 case LWPNROTATION:
16625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4922 times.
4922 if ( get_qr(qr_OLDSPRITEDRAWS) )
16626 {
16627 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
16628 "lweapon->Rotation");
16629 break;
16630 }
16631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4922 times.
4922 if(0!=(s=checkLWpn(ri->lwpn,"Rotation")))
16632 4922 ((weapon*)s)->rotation=(value/10000);
16633
16634 4922 break;
16635
16636 case LWPNEXTEND:
16637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(0!=(s=checkLWpn(ri->lwpn,"Extend")))
16638 16 ((weapon*)s)->extend=(value/10000);
16639
16640 16 break;
16641
16642 case LWPNOTILE:
16643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1841 times.
1841 if(0!=(s=checkLWpn(ri->lwpn,"OriginalTile")))
16644 {
16645 //zprint("LWPNOTILE before write: %d\n", ((weapon*)s)->o_tile);
16646 1841 ((weapon*)s)->o_tile=(value/10000);
16647 1841 ((weapon*)s)->ref_o_tile=(value/10000);
16648 //((weapon*)s)->script_wrote_otile=1; //Removing this as of 26th October, 2019 -Z
16649 //if at some future point we WANT writing ->Tile to also overwrite ->OriginalTile,
16650 //then either the user will need to manually write tile, or we can add a QR and
16651 // write ->tile here. 'script_wrote_otile' is out.
16652 //zprint("LWPNOTILE after write: %d\n", ((weapon*)s)->o_tile);
16653 1841 }
16654 1841 break;
16655
16656 case LWPNOCSET:
16657 if(0!=(s=checkLWpn(ri->lwpn,"OriginalCSet")))
16658 (((weapon*)s)->o_cset)|=(value/10000)&15;
16659
16660 break;
16661
16662 case LWPNHXOFS:
16663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60616 times.
60616 if(0!=(s=checkLWpn(ri->lwpn,"HitXOffset")))
16664 60616 (((weapon*)s)->hxofs)=(value/10000);
16665
16666 60616 break;
16667
16668 case LWPNHYOFS:
16669
1/2
✓ Branch 0 taken 60616 times.
✗ Branch 1 not taken.
60616 if(0!=(s=checkLWpn(ri->lwpn,"HitYOffset")))
16670 60616 (((weapon*)s)->hyofs)=(value/10000);
16671
16672 60616 break;
16673
16674 case LWPNXOFS:
16675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156 times.
156 if(0!=(s=checkLWpn(ri->lwpn,"DrawXOffset")))
16676 156 (((weapon*)s)->xofs)=(zfix)(value/10000);
16677
16678 156 break;
16679
16680 case LWPNYOFS:
16681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63470 times.
63470 if(0!=(s=checkLWpn(ri->lwpn,"DrawYOffset")))
16682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63470 times.
63470 (((weapon*)s)->yofs)=(zfix)(value/10000)+(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16683
16684 63470 break;
16685
16686 case LWPNSHADOWXOFS:
16687 if(0!=(s=checkLWpn(ri->lwpn,"ShadowXOffset")))
16688 (((weapon*)s)->shadowxofs)=(zfix)(value/10000);
16689
16690 break;
16691
16692 case LWPNSHADOWYOFS:
16693 if(0!=(s=checkLWpn(ri->lwpn,"ShadowYOffset")))
16694 (((weapon*)s)->shadowyofs)=(zfix)(value/10000);
16695
16696 break;
16697
16698 case LWPNTOTALDYOFFS:
16699 break; //READ-ONLY
16700
16701 case LWPNZOFS:
16702 if(0!=(s=checkLWpn(ri->lwpn,"DrawZOffset")))
16703 (((weapon*)s)->zofs)=(zfix)(value/10000);
16704
16705 break;
16706
16707 case LWPNHXSZ:
16708
1/2
✓ Branch 0 taken 61740 times.
✗ Branch 1 not taken.
61740 if(0!=(s=checkLWpn(ri->lwpn,"HitWidth")))
16709 61740 (((weapon*)s)->hit_width)=(value/10000);
16710
16711 61740 break;
16712
16713 case LWPNHYSZ:
16714
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61757 times.
61757 if(0!=(s=checkLWpn(ri->lwpn,"HitHeight")))
16715 61757 (((weapon*)s)->hit_height)=(value/10000);
16716
16717 61757 break;
16718
16719 case LWPNHZSZ:
16720 if(0!=(s=checkLWpn(ri->lwpn,"HitZHeight")))
16721 (((weapon*)s)->hzsz)=(value/10000);
16722
16723 break;
16724
16725 case LWPNTXSZ:
16726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(0!=(s=checkLWpn(ri->lwpn,"TileWidth")))
16727 10 (((weapon*)s)->txsz)=vbound((value/10000),1,20);
16728
16729 10 break;
16730
16731 case LWPNTYSZ:
16732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(0!=(s=checkLWpn(ri->lwpn,"TileHeight")))
16733 10 (((weapon*)s)->tysz)=vbound((value/10000),1,20);
16734
16735 10 break;
16736
16737 case LWPNMISCD:
16738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 497624 times.
497624 if(0!=(s=checkLWpn(ri->lwpn,"Misc")))
16739 {
16740 497624 int32_t a = vbound(ri->d[rINDEX]/10000,0,31);
16741 497624 (((weapon*)(s))->miscellaneous[a])=value;
16742 497624 }
16743
16744 497624 break;
16745
16746 case LWPNCOLLDET:
16747
1/2
✓ Branch 0 taken 16104 times.
✗ Branch 1 not taken.
16104 if(0!=(s=checkLWpn(ri->lwpn,"CollDetection")))
16748 16104 (((weapon*)(s))->scriptcoldet)=value/10000;
16749
16750 16104 break;
16751
16752 case LWPNENGINEANIMATE:
16753 if(0!=(s=checkLWpn(ri->lwpn,"Animation")))
16754 (((weapon*)(s))->do_animation)=(value ? 1 : 0);
16755
16756 break;
16757
16758 case LWPNPARENT:
16759 {
16760 //int32_t pitm = (vbound(value/10000,1,(MAXITEMS-1)));
16761 //zprint("Attempting to set ParentItem to: %d\n", pitm);
16762
16763 if(0!=(s=checkLWpn(ri->lwpn,"Parent")))
16764 (((weapon*)(s))->parentitem)=(vbound(value/10000,-1,(MAXITEMS-1)));
16765 break;
16766 }
16767
16768 case LWPNLEVEL:
16769 if(0!=(s=checkLWpn(ri->lwpn,"Level")))
16770 (((weapon*)(s))->type)=value/10000;
16771
16772 break;
16773
16774 case LWPNSCRIPT:
16775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60886 times.
60886 if(0!=(s=checkLWpn(ri->lwpn,"Script")))
16776 {
16777 60886 FFScript::deallocateAllArrays(ScriptType::Lwpn, ri->lwpn);
16778 60886 (((weapon*)(s))->weaponscript)=vbound(value/10000,0,NUMSCRIPTWEAPONS-1);
16779
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60886 times.
60886 if ( get_qr(qr_CLEARINITDONSCRIPTCHANGE))
16780 {
16781
2/2
✓ Branch 0 taken 487088 times.
✓ Branch 1 taken 60886 times.
547974 for(int32_t q=0; q<8; q++)
16782 487088 (((weapon*)(s))->weap_initd[q]) = 0;
16783 60886 }
16784 60886 }
16785 60886 break;
16786
16787 case LWPNUSEWEAPON:
16788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 603 times.
603 if(0!=(s=checkLWpn(ri->lwpn,"Weapon")))
16789 603 (((weapon*)(s))->useweapon)=vbound(value/10000,0,255);
16790
16791 603 break;
16792
16793 case LWPNUSEDEFENCE:
16794 if(0!=(s=checkLWpn(ri->lwpn,"Defense")))
16795 (((weapon*)(s))->usedefence)=vbound(value/10000,0,255);
16796
16797 break;
16798
16799 case LWPNINITD:
16800 {
16801 206 int32_t a = vbound((ri->d[rINDEX] / 10000),0,7);
16802
1/2
✓ Branch 0 taken 206 times.
✗ Branch 1 not taken.
206 if(0!=(s=checkLWpn(ri->lwpn,"InitD[]")))
16803 {
16804 206 (((weapon*)(s))->weap_initd[a])=value;
16805 206 }
16806 206 break;
16807 }
16808 case LWPNFALLCLK:
16809 if(0!=(s=checkLWpn(ri->lwpn,"Falling")))
16810 {
16811 if(((weapon*)(s))->fallclk != 0 && value == 0)
16812 {
16813 ((weapon*)(s))->cs = ((weapon*)(s))->old_cset;
16814 ((weapon*)(s))->tile = ((weapon*)(s))->o_tile;
16815 }
16816 else if(((weapon*)(s))->fallclk == 0 && value != 0) ((weapon*)(s))->old_cset = ((weapon*)(s))->cs;
16817 ((weapon*)(s))->fallclk = vbound(value/10000,0,70);
16818 }
16819 break;
16820 case LWPNFALLCMB:
16821 if(0!=(s=checkLWpn(ri->lwpn,"FallCombo")))
16822 {
16823 ((weapon*)(s))->fallCombo = vbound(value/10000,0,MAXCOMBOS-1);
16824 }
16825 break;
16826 case LWPNDROWNCLK:
16827 if(0!=(s=checkLWpn(ri->lwpn,"Drowning")))
16828 {
16829 if(((weapon*)(s))->drownclk != 0 && value == 0)
16830 {
16831 ((weapon*)(s))->cs = ((weapon*)(s))->old_cset;
16832 ((weapon*)(s))->tile = ((weapon*)(s))->o_tile;
16833 }
16834 else if(((weapon*)(s))->drownclk == 0 && value != 0) ((weapon*)(s))->old_cset = ((weapon*)(s))->cs;
16835 ((weapon*)(s))->drownclk = vbound(value/10000,0,70);
16836 }
16837 break;
16838 case LWPNDROWNCMB:
16839 if(0!=(s=checkLWpn(ri->lwpn,"DrownCombo")))
16840 {
16841 ((weapon*)(s))->drownCombo = vbound(value/10000,0,MAXCOMBOS-1);
16842 }
16843 break;
16844 case LWPNFAKEZ:
16845 if(0!=(s=checkLWpn(ri->lwpn,"FakeZ")))
16846 {
16847 ((weapon*)s)->fakez=get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000);
16848 if(((weapon*)s)->fakez < 0) ((weapon*)s)->fakez = zfix(0);
16849 }
16850
16851 break;
16852
16853 case LWPNMOVEFLAGS:
16854 {
16855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 265 times.
265 if(0!=(s=checkLWpn(ri->lwpn,"MoveFlags[]")))
16856 {
16857 265 int32_t indx = ri->d[rINDEX]/10000;
16858
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 265 times.
265 if(BC::checkBounds(indx, 0, 10, "lweapon->MoveFlags[]") == SH::_NoError)
16859 {
16860 //All bits, in order, of a single byte; just use bitwise
16861 265 int32_t bit = 1<<indx;
16862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 265 times.
265 if(value)
16863 ((weapon*)(s))->moveflags |= bit;
16864 else
16865 265 ((weapon*)(s))->moveflags &= ~bit;
16866 265 }
16867 265 }
16868 265 break;
16869 }
16870 case LWPNFLAGS:
16871 {
16872 if(0!=(s=checkLWpn(ri->lwpn,"Flags[]")))
16873 {
16874 int32_t indx = ri->d[rINDEX]/10000;
16875 if(BC::checkBounds(indx, 0, WFLAG_MAX, "lweapon->Flags[]") == SH::_NoError)
16876 {
16877 //All bits, in order, of a single byte; just use bitwise
16878 int32_t bit = 1<<indx;
16879 if(value)
16880 ((weapon*)(s))->misc_wflags |= bit;
16881 else
16882 ((weapon*)(s))->misc_wflags &= ~bit;
16883 }
16884 }
16885 break;
16886 }
16887
16888 case LWPNGLOWRAD:
16889 if(0!=(s=checkLWpn(ri->lwpn,"LightRadius")))
16890 {
16891 ((weapon*)(s))->glowRad = vbound(value/10000,0,255);
16892 }
16893 break;
16894
16895 case LWPNGLOWSHP:
16896 if(0!=(s=checkLWpn(ri->lwpn,"LightShape")))
16897 {
16898 ((weapon*)(s))->glowShape = vbound(value/10000,0,255);
16899 }
16900 break;
16901
16902 case LWPNUNBL:
16903 if(0!=(s=checkLWpn(ri->lwpn,"Unblockable")))
16904 {
16905 ((weapon*)(s))->unblockable = (value/10000)&WPNUNB_ALL;
16906 }
16907 break;
16908
16909 case LWPNSHADOWSPR:
16910 if(0!=(s=checkLWpn(ri->lwpn,"ShadowSprite")))
16911 {
16912 ((weapon*)(s))->spr_shadow = vbound(value/10000, 0, 255);
16913 }
16914 break;
16915 case LWSWHOOKED:
16916 break; //read-only
16917 case LWPNTIMEOUT:
16918 if(0!=(s=checkLWpn(ri->lwpn,"Timeout")))
16919 {
16920 ((weapon*)(s))->weap_timeout = vbound(value/10000,0,214748);
16921 }
16922 break;
16923 case LWPNDEATHITEM:
16924 if(0!=(s=checkLWpn(ri->lwpn,"DeathItem")))
16925 {
16926 ((weapon*)(s))->death_spawnitem = vbound(value/10000,-1,MAXITEMS-1);
16927 }
16928 break;
16929 case LWPNDEATHDROPSET:
16930 if(0!=(s=checkLWpn(ri->lwpn,"DeathDropset")))
16931 {
16932 ((weapon*)(s))->death_spawndropset = vbound(value/10000,-1,MAXITEMDROPSETS-1);
16933 }
16934 break;
16935 case LWPNDEATHIPICKUP:
16936 if(0!=(s=checkLWpn(ri->lwpn,"DeathItemPFlags")))
16937 {
16938 ((weapon*)(s))->death_item_pflags = value/10000;
16939 }
16940 break;
16941 case LWPNDEATHSPRITE:
16942 if(0!=(s=checkLWpn(ri->lwpn,"DeathSprite")))
16943 {
16944 ((weapon*)(s))->death_sprite = vbound(value/10000,-255,MAXWPNS-1);
16945 }
16946 break;
16947 case LWPNDEATHSFX:
16948 if(0!=(s=checkLWpn(ri->lwpn,"DeathSFX")))
16949 {
16950 ((weapon*)(s))->death_sfx = vbound(value/10000,0,WAV_COUNT);
16951 }
16952 break;
16953 case LWPNLIFTLEVEL:
16954 if(0!=(s=checkLWpn(ri->lwpn,"LiftLevel")))
16955 {
16956 ((weapon*)(s))->lift_level = vbound(value/10000,0,255);
16957 }
16958 break;
16959 case LWPNLIFTTIME:
16960 if(0!=(s=checkLWpn(ri->lwpn,"LiftTime")))
16961 {
16962 ((weapon*)(s))->lift_time = vbound(value/10000,0,255);
16963 }
16964 break;
16965 case LWPNLIFTHEIGHT:
16966 if(0!=(s=checkLWpn(ri->lwpn,"LiftHeight")))
16967 {
16968 ((weapon*)(s))->lift_height = zslongToFix(value);
16969 }
16970 break;
16971
16972 ///----------------------------------------------------------------------------------------------------//
16973 //EWeapon Variables
16974 case EWPNSCALE:
16975 if ( get_qr(qr_OLDSPRITEDRAWS) )
16976 {
16977 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
16978 "eweapon->Scale");
16979 break;
16980 }
16981 if(0!=(s=checkEWpn(ri->ewpn,"Scale")))
16982 ((weapon*)s)->scale=(zfix)(value/100.0);
16983
16984 break;
16985
16986 case EWPNX:
16987
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226569 times.
226569 if(0!=(s=checkEWpn(ri->ewpn,"X")))
16988
2/2
✓ Branch 0 taken 7282 times.
✓ Branch 1 taken 219287 times.
226569 ((weapon*)s)->x = (get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000));
16989
16990 226569 break;
16991
16992 case SPRITEMAXEWPN:
16993 {
16994 //No bounds check, as this is a universal function and works from NULL pointers!
16995 Ewpns.setMax(vbound((value/10000),1,MAX_EWPN_SPRITES));
16996 break;
16997 }
16998
16999 case EWPNY:
17000
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226856 times.
226856 if(0!=(s=checkEWpn(ri->ewpn,"Y")))
17001
2/2
✓ Branch 0 taken 7170 times.
✓ Branch 1 taken 219686 times.
226856 ((weapon*)s)->y = (get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000));
17002
17003 226856 break;
17004
17005 case EWPNZ:
17006
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6823 times.
6823 if(0!=(s=checkEWpn(ri->ewpn,"Z")))
17007 {
17008
2/2
✓ Branch 0 taken 1203 times.
✓ Branch 1 taken 5620 times.
6823 ((weapon*)s)->z=get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000);
17009
1/2
✓ Branch 0 taken 6823 times.
✗ Branch 1 not taken.
6823 if(((weapon*)s)->z < 0) ((weapon*)s)->z = zfix(0);
17010 6823 }
17011
17012 6823 break;
17013
17014 case EWPNJUMP:
17015
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6048 times.
6048 if(0!=(s=checkEWpn(ri->ewpn,"Jump")))
17016 6048 ((weapon*)s)->fall=zslongToFix(value)*-100;
17017
17018 6048 break;
17019
17020 case EWPNFAKEJUMP:
17021 if(0!=(s=checkEWpn(ri->ewpn,"FakeJump")))
17022 ((weapon*)s)->fakefall=zslongToFix(value)*-100;
17023
17024 break;
17025
17026 case EWPNDIR:
17027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138270 times.
138270 if(0!=(s=checkEWpn(ri->ewpn,"Dir")))
17028 {
17029 138270 ((weapon*)s)->dir=(value/10000);
17030 138270 ((weapon*)s)->doAutoRotate(true);
17031 138270 }
17032
17033 138270 break;
17034
17035 case EWPNLEVEL:
17036 if(0!=(s=checkEWpn(ri->ewpn,"Level")))
17037 ((weapon*)s)->type=(value/10000);
17038
17039 break;
17040
17041 case EWPNGRAVITY:
17042 if(0!=(s=checkEWpn(ri->ewpn,"Gravity")))
17043 {
17044 if(value)
17045 ((weapon*)s)->moveflags |= FLAG_OBEYS_GRAV;
17046 else
17047 ((weapon*)s)->moveflags &= ~FLAG_OBEYS_GRAV;
17048 }
17049 break;
17050
17051 case EWPNSTEP:
17052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264908 times.
264908 if(0!=(s=checkEWpn(ri->ewpn,"Step")))
17053 {
17054
3/4
✓ Branch 0 taken 243133 times.
✓ Branch 1 taken 21775 times.
✓ Branch 2 taken 243133 times.
✗ Branch 3 not taken.
264908 if ( get_qr(qr_STEP_IS_FLOAT) || replay_is_active() )
17055 {
17056 264908 ((weapon*)s)->step= zslongToFix(value / 100);
17057 264908 }
17058 else
17059 {
17060 //old, buggy code replication, round two: Go! -Z
17061 //zfix val = zslongToFix(value);
17062 //val.doFloor();
17063 //((weapon*)s)->step = ((val / 100.0).getFloat());
17064
17065 //old, buggy code replication, round THREE: Go! -Z
17066 ((weapon*)s)->step = ((value/10000)/100.0);
17067 //zprint2("ewpn step is %d\n", ((weapon*)s)->step);
17068 }
17069 264908 }
17070
17071 264908 break;
17072
17073 case EWPNANGLE:
17074
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134925 times.
134925 if(0!=(s=checkEWpn(ri->ewpn,"Angle")))
17075 {
17076 134925 ((weapon*)s)->angle=(double)(value/10000.0);
17077 134925 ((weapon*)(s))->doAutoRotate();
17078 134925 }
17079
17080 134925 break;
17081
17082 case EWPNDEGANGLE:
17083 if(0!=(s=checkEWpn(ri->ewpn,"DegAngle")))
17084 {
17085 double rangle = (value / 10000.0) * (PI / 180.0);
17086 ((weapon*)s)->angle=(double)(rangle);
17087 ((weapon*)(s))->doAutoRotate();
17088 }
17089
17090 break;
17091
17092 case EWPNVX:
17093 if(0!=(s=checkEWpn(ri->ewpn,"Vx")))
17094 {
17095 double vy;
17096 double vx = (value / 10000.0);
17097 if (((weapon*)(s))->angular)
17098 vy = zc::math::Sin(((weapon*)s)->angle)*((weapon*)s)->step;
17099 else
17100 {
17101 switch(NORMAL_DIR(((weapon*)(s))->dir))
17102 {
17103 case l_up:
17104 case r_up:
17105 case up:
17106 vy = -1.0*((weapon*)s)->step;
17107 break;
17108 case l_down:
17109 case r_down:
17110 case down:
17111 vy = ((weapon*)s)->step;
17112 break;
17113
17114 default:
17115 vy = 0;
17116 break;
17117 }
17118 }
17119 ((weapon*)s)->angular = true;
17120 ((weapon*)s)->angle=atan2(vy, vx);
17121 ((weapon*)s)->step=FFCore.Distance(0, 0, vx, vy)/10000;
17122 ((weapon*)(s))->doAutoRotate();
17123 }
17124
17125 break;
17126
17127 case EWPNVY:
17128 if(0!=(s=checkEWpn(ri->ewpn,"Vy")))
17129 {
17130 double vx;
17131 double vy = (value / 10000.0);
17132 if (((weapon*)(s))->angular)
17133 vx = zc::math::Cos(((weapon*)s)->angle)*((weapon*)s)->step;
17134 else
17135 {
17136 switch(NORMAL_DIR(((weapon*)(s))->dir))
17137 {
17138 case l_up:
17139 case l_down:
17140 case left:
17141 vx = -1.0*((weapon*)s)->step;
17142 break;
17143 case r_down:
17144 case r_up:
17145 case right:
17146 vx = ((weapon*)s)->step;
17147 break;
17148
17149 default:
17150 vx = 0;
17151 break;
17152 }
17153 }
17154 ((weapon*)s)->angular = true;
17155 ((weapon*)s)->angle=atan2(vy, vx);
17156 ((weapon*)s)->step=FFCore.Distance(0, 0, vx, vy)/10000;
17157 ((weapon*)(s))->doAutoRotate();
17158 }
17159
17160 break;
17161
17162 case EWPNANGULAR:
17163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131702 times.
131702 if(0!=(s=checkEWpn(ri->ewpn,"Angular")))
17164 {
17165 131702 ((weapon*)s)->angular=(value!=0);
17166 131702 ((weapon*)(s))->doAutoRotate(false, true);
17167 131702 }
17168
17169 131702 break;
17170
17171 case EWPNAUTOROTATE:
17172 if(0!=(s=checkEWpn(ri->ewpn,"AutoRotate")))
17173 {
17174 ((weapon*)s)->autorotate=(value!=0);
17175 ((weapon*)(s))->doAutoRotate(false, true);
17176 }
17177
17178 break;
17179
17180 case EWPNBEHIND:
17181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
47 if(0!=(s=checkEWpn(ri->ewpn,"Behind")))
17182 47 ((weapon*)s)->behind=(value!=0);
17183
17184 47 break;
17185
17186 case EWPNDRAWTYPE:
17187
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12175 times.
12175 if(0!=(s=checkEWpn(ri->ewpn,"DrawStyle")))
17188 12175 ((weapon*)s)->drawstyle=(value/10000);
17189
17190 12175 break;
17191
17192 case EWPNPOWER:
17193
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132679 times.
132679 if(0!=(s=checkEWpn(ri->ewpn,"Damage")))
17194 132679 ((weapon*)s)->power=(value/10000);
17195
17196 132679 break;
17197
17198 case EWPNDEAD:
17199
1/2
✓ Branch 0 taken 23997 times.
✗ Branch 1 not taken.
23997 if(0!=(s=checkEWpn(ri->ewpn,"DeadState")))
17200 {
17201 23997 auto dead = value/10000;
17202 23997 ((weapon*)s)->dead=dead;
17203
2/2
✓ Branch 0 taken 15476 times.
✓ Branch 1 taken 8521 times.
23997 if(dead != 0) ((weapon*)s)->weapon_dying_frame = false;
17204 23997 }
17205
17206 23997 break;
17207
17208 case EWPNID:
17209 if(0!=(s=checkEWpn(ri->ewpn,"ID")))
17210 ((weapon*)s)->id=(value/10000);
17211
17212 break;
17213
17214 case EWPNTILE:
17215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9747 times.
9747 if(0!=(s=checkEWpn(ri->ewpn,"Tile")))
17216 9747 ((weapon*)s)->tile=(value/10000);
17217
17218 9747 break;
17219
17220 case EWPNSCRIPTTILE:
17221 if(0!=(s=checkEWpn(ri->ewpn,"ScriptTile")))
17222 ((weapon*)s)->scripttile=vbound((value/10000),-1, NEWMAXTILES-1);
17223
17224 break;
17225
17226 case EWPNSCRIPTFLIP:
17227 if(0!=(s=checkEWpn(ri->ewpn,"ScriptFlip")))
17228 ((weapon*)s)->scriptflip=vbound((value/10000),-1, 127);
17229
17230 break;
17231
17232 case EWPNCSET:
17233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2072 times.
2072 if(0!=(s=checkEWpn(ri->ewpn,"CSet")))
17234 2072 ((weapon*)s)->cs=(value/10000)&15;
17235
17236 2072 break;
17237
17238 case EWPNFLASHCSET:
17239 if(0!=(s=checkEWpn(ri->ewpn,"FlashCSet")))
17240 (((weapon*)s)->o_cset)|=(value/10000)<<4;
17241
17242 break;
17243
17244 case EWPNFRAMES:
17245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41 times.
41 if(0!=(s=checkEWpn(ri->ewpn,"NumFrames")))
17246 41 ((weapon*)s)->frames=(value/10000);
17247
17248 41 break;
17249
17250 case EWPNFRAME:
17251 if(0!=(s=checkEWpn(ri->ewpn,"Frame")))
17252 ((weapon*)s)->aframe=(value/10000);
17253
17254 break;
17255
17256 case EWPNASPEED:
17257
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41 times.
41 if(0!=(s=checkEWpn(ri->ewpn,"ASpeed")))
17258 41 ((weapon*)s)->o_speed=(value/10000);
17259
17260 41 break;
17261
17262 case EWPNFLASH:
17263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 549 times.
549 if(0!=(s=checkEWpn(ri->ewpn,"Flash")))
17264 549 ((weapon*)s)->flash=(value/10000);
17265
17266 549 break;
17267
17268 case EWPNFLIP:
17269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49622 times.
49622 if(0!=(s=checkEWpn(ri->ewpn,"Flip")))
17270 49622 ((weapon*)s)->flip=(value/10000);
17271
17272 49622 break;
17273
17274 case EWPNROTATION:
17275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1104 times.
1104 if ( get_qr(qr_OLDSPRITEDRAWS) )
17276 {
17277 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
17278 "eweapon->Rotation");
17279 break;
17280 }
17281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1104 times.
1104 if(0!=(s=checkEWpn(ri->ewpn,"Rotation")))
17282 1104 ((weapon*)s)->rotation=(value/10000);
17283
17284 1104 break;
17285
17286 case EWPNEXTEND:
17287
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111461 times.
111461 if(0!=(s=checkEWpn(ri->ewpn,"Extend")))
17288 111461 ((weapon*)s)->extend=(value/10000);
17289
17290 111461 break;
17291
17292 case EWPNOTILE:
17293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4552 times.
4552 if(0!=(s=checkEWpn(ri->ewpn,"OriginalTile")))
17294 {
17295 4552 ((weapon*)s)->o_tile=(value/10000);
17296 4552 ((weapon*)s)->ref_o_tile=(value/10000);
17297 4552 }
17298
17299 4552 break;
17300
17301 case EWPNOCSET:
17302 if(0!=(s=checkEWpn(ri->ewpn,"OriginalCSet")))
17303 (((weapon*)s)->o_cset)|=(value/10000)&15;
17304
17305 break;
17306
17307 case EWPNHXOFS:
17308
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138269 times.
138269 if(0!=(s=checkEWpn(ri->ewpn,"HitXOffset")))
17309 138269 (((weapon*)s)->hxofs)=(value/10000);
17310
17311 138269 break;
17312
17313 case EWPNHYOFS:
17314
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137776 times.
137776 if(0!=(s=checkEWpn(ri->ewpn,"HitYOffset")))
17315 137776 (((weapon*)s)->hyofs)=(value/10000);
17316
17317 137776 break;
17318
17319 case EWPNXOFS:
17320
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 35366 times.
35370 if(0!=(s=checkEWpn(ri->ewpn,"DrawXOffset")))
17321 35366 (((weapon*)s)->xofs)=(zfix)(value/10000);
17322
17323 35370 break;
17324
17325 case EWPNYOFS:
17326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38448 times.
38448 if(0!=(s=checkEWpn(ri->ewpn,"DrawYOffset")))
17327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38448 times.
38448 (((weapon*)s)->yofs)=(zfix)(value/10000)+(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
17328
17329 38448 break;
17330 case EWPNTOTALDYOFFS:
17331 break; //READ-ONLY
17332
17333 case EWPNSHADOWXOFS:
17334 if(0!=(s=checkEWpn(ri->ewpn,"ShadowXOffset")))
17335 (((weapon*)s)->shadowxofs)=(zfix)(value/10000);
17336
17337 break;
17338
17339 case EWPNSHADOWYOFS:
17340 if(0!=(s=checkEWpn(ri->ewpn,"ShadowYOffset")))
17341 (((weapon*)s)->shadowyofs)=(zfix)(value/10000);
17342
17343 break;
17344
17345 case EWPNZOFS:
17346 if(0!=(s=checkEWpn(ri->ewpn,"DrawZOffset")))
17347 (((weapon*)s)->zofs)=(zfix)(value/10000);
17348
17349 break;
17350
17351 case EWPNHXSZ:
17352
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 234661 times.
234661 if(0!=(s=checkEWpn(ri->ewpn,"HitWidth")))
17353 234661 (((weapon*)s)->hit_width)=(value/10000);
17354
17355 234661 break;
17356
17357 case EWPNHYSZ:
17358
1/2
✓ Branch 0 taken 234074 times.
✗ Branch 1 not taken.
234074 if(0!=(s=checkEWpn(ri->ewpn,"HitHeight")))
17359 234074 (((weapon*)s)->hit_height)=(value/10000);
17360
17361 234074 break;
17362
17363 case EWPNHZSZ:
17364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if(0!=(s=checkEWpn(ri->ewpn,"HitZHeight")))
17365 44 (((weapon*)s)->hzsz)=(value/10000);
17366
17367 44 break;
17368
17369 case EWPNTXSZ:
17370
1/2
✓ Branch 0 taken 111461 times.
✗ Branch 1 not taken.
111461 if(0!=(s=checkEWpn(ri->ewpn,"TileWidth")))
17371 111461 (((weapon*)s)->txsz)=vbound((value/10000),1,20);
17372
17373 111461 break;
17374
17375 case EWPNTYSZ:
17376
1/2
✓ Branch 0 taken 111461 times.
✗ Branch 1 not taken.
111461 if(0!=(s=checkEWpn(ri->ewpn,"TileHeight")))
17377 111461 (((weapon*)s)->tysz)=vbound((value/10000),1,20);
17378
17379 111461 break;
17380
17381 case EWPNMISCD:
17382
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 910117 times.
910117 if(0!=(s=checkEWpn(ri->ewpn,"Misc")))
17383 {
17384 910117 int32_t a = vbound(ri->d[rINDEX]/10000,0,31);
17385 910117 (((weapon*)(s))->miscellaneous[a])=value;
17386 910117 }
17387
17388 910117 break;
17389
17390 case EWPNCOLLDET:
17391
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20016 times.
20016 if(0!=(s=checkEWpn(ri->ewpn,"CollDetection")))
17392 20016 (((weapon*)(s))->scriptcoldet)=value/10000;
17393
17394 20016 break;
17395
17396 case EWPNENGINEANIMATE:
17397 if(0!=(s=checkEWpn(ri->ewpn,"Animation")))
17398 (((weapon*)(s))->do_animation)=(value ? 1 : 0);
17399
17400 break;
17401
17402
17403 case EWPNPARENTUID:
17404 if(0!=(s=checkEWpn(ri->ewpn, "ParentUID")))
17405 (((weapon*)(s))->parent_script_UID) = value; //literal, not *10000
17406 break;
17407
17408 case EWPNPARENT:
17409 if(0!=(s=checkEWpn(ri->ewpn, "Parent")))
17410 (((weapon*)(s))->parentid)= ( (get_qr(qr_OLDEWPNPARENT)) ? value / 10000 : value );
17411
17412 break;
17413
17414 case EWPNSCRIPT:
17415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1275 times.
1275 if(0!=(s=checkEWpn(ri->ewpn,"Script")))
17416 {
17417 1275 FFScript::deallocateAllArrays(ScriptType::Ewpn, ri->ewpn);
17418 1275 (((weapon*)(s))->weaponscript)=vbound(value/10000,0,NUMSCRIPTWEAPONS-1);
17419
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1275 times.
1275 if ( get_qr(qr_CLEARINITDONSCRIPTCHANGE))
17420 {
17421
2/2
✓ Branch 0 taken 10200 times.
✓ Branch 1 taken 1275 times.
11475 for(int32_t q=0; q<8; q++)
17422 10200 (((weapon*)(s))->weap_initd[q]) = 0;
17423 1275 }
17424 1275 }
17425 1275 break;
17426
17427 case EWPNINITD:
17428 {
17429 4214 int32_t a = vbound((ri->d[rINDEX] / 10000),0,7);
17430
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4214 times.
4214 if(0!=(s=checkEWpn(ri->ewpn,"InitD[]")))
17431 {
17432 4214 (((weapon*)(s))->weap_initd[a])=value;
17433 4214 }
17434 4214 break;
17435 }
17436 case EWPNFALLCLK:
17437 if(0!=(s=checkEWpn(ri->ewpn,"Falling")))
17438 {
17439 if(((weapon*)(s))->fallclk != 0 && value == 0)
17440 {
17441 ((weapon*)(s))->cs = ((weapon*)(s))->old_cset;
17442 ((weapon*)(s))->tile = ((weapon*)(s))->o_tile;
17443 }
17444 else if(((weapon*)(s))->fallclk == 0 && value != 0) ((weapon*)(s))->old_cset = ((weapon*)(s))->cs;
17445 ((weapon*)(s))->fallclk = vbound(value/10000,0,70);
17446 }
17447 break;
17448 case EWPNFALLCMB:
17449 if(0!=(s=checkEWpn(ri->ewpn,"FallCombo")))
17450 {
17451 ((weapon*)(s))->fallCombo = vbound(value/10000,0,MAXCOMBOS-1);
17452 }
17453 break;
17454 case EWPNDROWNCLK:
17455 if(0!=(s=checkEWpn(ri->ewpn,"Drowning")))
17456 {
17457 if(((weapon*)(s))->drownclk != 0 && value == 0)
17458 {
17459 ((weapon*)(s))->cs = ((weapon*)(s))->old_cset;
17460 ((weapon*)(s))->tile = ((weapon*)(s))->o_tile;
17461 }
17462 else if(((weapon*)(s))->drownclk == 0 && value != 0) ((weapon*)(s))->old_cset = ((weapon*)(s))->cs;
17463 ((weapon*)(s))->drownclk = vbound(value/10000,0,70);
17464 }
17465 break;
17466 case EWPNDROWNCMB:
17467 if(0!=(s=checkEWpn(ri->ewpn,"DrownCombo")))
17468 {
17469 ((weapon*)(s))->drownCombo = vbound(value/10000,0,MAXCOMBOS-1);
17470 }
17471 break;
17472 case EWPNFAKEZ:
17473 if(0!=(s=checkEWpn(ri->ewpn,"FakeZ")))
17474 {
17475 ((weapon*)s)->fakez=get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000);
17476 if(((weapon*)s)->fakez < 0) ((weapon*)s)->fakez = zfix(0);
17477 }
17478
17479 break;
17480
17481 case EWPNMOVEFLAGS:
17482 {
17483 if(0!=(s=checkEWpn(ri->ewpn,"MoveFlags[]")))
17484 {
17485 int32_t indx = ri->d[rINDEX]/10000;
17486 if(BC::checkBounds(indx, 0, 10, "eweapon->MoveFlags[]") == SH::_NoError)
17487 {
17488 //All bits, in order, of a single byte; just use bitwise
17489 int32_t bit = 1<<indx;
17490 if(value)
17491 ((weapon*)(s))->moveflags |= bit;
17492 else
17493 ((weapon*)(s))->moveflags &= ~bit;
17494 }
17495 }
17496 break;
17497 }
17498 case EWPNFLAGS:
17499 {
17500 if(0!=(s=checkEWpn(ri->ewpn,"Flags[]")))
17501 {
17502 int32_t indx = ri->d[rINDEX]/10000;
17503 if(BC::checkBounds(indx, 0, WFLAG_MAX, "eweapon->Flags[]") == SH::_NoError)
17504 {
17505 //All bits, in order, of a single byte; just use bitwise
17506 int32_t bit = 1<<indx;
17507 if(value)
17508 ((weapon*)(s))->misc_wflags |= bit;
17509 else
17510 ((weapon*)(s))->misc_wflags &= ~bit;
17511 }
17512 }
17513 break;
17514 }
17515
17516 case EWPNGLOWRAD:
17517 if(0!=(s=checkEWpn(ri->ewpn,"LightRadius")))
17518 {
17519 ((weapon*)(s))->glowRad = vbound(value/10000,0,255);
17520 }
17521 break;
17522 case EWPNGLOWSHP:
17523 if(0!=(s=checkEWpn(ri->ewpn,"LightShape")))
17524 {
17525 ((weapon*)(s))->glowShape = vbound(value/10000,0,255);
17526 }
17527 break;
17528
17529 case EWPNUNBL:
17530 if(0!=(s=checkEWpn(ri->ewpn,"Unblockable")))
17531 {
17532 ((weapon*)(s))->unblockable = (value/10000)&WPNUNB_ALL;
17533 }
17534 break;
17535
17536 case EWPNSHADOWSPR:
17537 if(0!=(s=checkEWpn(ri->ewpn,"ShadowSprite")))
17538 {
17539 ((weapon*)(s))->spr_shadow = vbound(value/10000, 0, 255);
17540 }
17541 break;
17542 case EWSWHOOKED:
17543 break; //read-only
17544 case EWPNTIMEOUT:
17545 if(0!=(s=checkEWpn(ri->ewpn,"Timeout")))
17546 {
17547 ((weapon*)(s))->weap_timeout = vbound(value/10000,0,214748);
17548 }
17549 break;case EWPNDEATHITEM:
17550 if(0!=(s=checkEWpn(ri->ewpn,"DeathItem")))
17551 {
17552 ((weapon*)(s))->death_spawnitem = vbound(value/10000,-1,MAXITEMS-1);
17553 }
17554 break;
17555 case EWPNDEATHDROPSET:
17556 if(0!=(s=checkEWpn(ri->ewpn,"DeathDropset")))
17557 {
17558 ((weapon*)(s))->death_spawndropset = vbound(value/10000,-1,MAXITEMDROPSETS-1);
17559 }
17560 break;
17561 case EWPNDEATHIPICKUP:
17562 if(0!=(s=checkEWpn(ri->ewpn,"DeathItemPFlags")))
17563 {
17564 ((weapon*)(s))->death_item_pflags = value/10000;
17565 }
17566 break;
17567 case EWPNDEATHSPRITE:
17568 if(0!=(s=checkEWpn(ri->ewpn,"DeathSprite")))
17569 {
17570 ((weapon*)(s))->death_sprite = vbound(value/10000,-255,MAXWPNS-1);
17571 }
17572 break;
17573 case EWPNDEATHSFX:
17574 if(0!=(s=checkEWpn(ri->ewpn,"DeathSFX")))
17575 {
17576 ((weapon*)(s))->death_sfx = vbound(value/10000,0,WAV_COUNT);
17577 }
17578 break;
17579 case EWPNLIFTLEVEL:
17580 if(0!=(s=checkEWpn(ri->ewpn,"LiftLevel")))
17581 {
17582 ((weapon*)(s))->lift_level = vbound(value/10000,0,255);
17583 }
17584 break;
17585 case EWPNLIFTTIME:
17586 if(0!=(s=checkEWpn(ri->ewpn,"LiftTime")))
17587 {
17588 ((weapon*)(s))->lift_time = vbound(value/10000,0,255);
17589 }
17590 break;
17591 case EWPNLIFTHEIGHT:
17592 if(0!=(s=checkEWpn(ri->ewpn,"LiftHeight")))
17593 {
17594 ((weapon*)(s))->lift_height = zslongToFix(value);
17595 }
17596 break;
17597
17598 ///----------------------------------------------------------------------------------------------------//
17599 //NPC Variables
17600
17601 //Fixs are all a bit different
17602 case NPCX:
17603 {
17604
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1036999 times.
1037003 if(GuyH::loadNPC(ri->guyref, "npc->X") == SH::_NoError)
17605 {
17606
2/2
✓ Branch 0 taken 95921 times.
✓ Branch 1 taken 941078 times.
1036999 GuyH::getNPC()->x = get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000);
17607
17608
1/2
✓ Branch 0 taken 1036999 times.
✗ Branch 1 not taken.
1036999 if(GuyH::hasHero())
17609 Hero.setXfix(get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000));
17610 1036999 }
17611 }
17612 1037003 break;
17613
17614 case NPCSCALE:
17615 {
17616 if ( get_qr(qr_OLDSPRITEDRAWS) )
17617 {
17618 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
17619 "npc->Scale");
17620 break;
17621 }
17622 if(GuyH::loadNPC(ri->guyref, "npc->Scale") == SH::_NoError)
17623 {
17624 GuyH::getNPC()->scale = (value / 100.0);
17625 }
17626 }
17627 break;
17628
17629 case NPCIMMORTAL:
17630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(GuyH::loadNPC(ri->guyref, "npc->Immortal") == SH::_NoError)
17631 {
17632 3 GuyH::getNPC()->immortal = (value ? true : false);
17633 3 }
17634 3 break;
17635
17636 case NPCNOSLIDE:
17637 if(GuyH::loadNPC(ri->guyref, "npc->NoSlide") == SH::_NoError)
17638 {
17639 if(value)
17640 {
17641 GuyH::getNPC()->knockbackflags |= FLAG_NOSLIDE;
17642 }
17643 else
17644 {
17645 GuyH::getNPC()->knockbackflags &= ~FLAG_NOSLIDE;
17646 }
17647 }
17648 break;
17649
17650 case NPCNOSCRIPTKB:
17651 if(GuyH::loadNPC(ri->guyref, "npc->NoScriptKnockback") == SH::_NoError)
17652 {
17653 if(value)
17654 {
17655 GuyH::getNPC()->knockbackflags |= FLAG_NOSCRIPTKNOCKBACK;
17656 }
17657 else
17658 {
17659 GuyH::getNPC()->knockbackflags &= ~FLAG_NOSCRIPTKNOCKBACK;
17660 }
17661 }
17662 break;
17663
17664 case NPCKNOCKBACKSPEED:
17665 if(GuyH::loadNPC(ri->guyref, "npc->NoKnockback") == SH::_NoError)
17666 {
17667 GuyH::getNPC()->knockbackSpeed = vbound(value/10000, 0, 255);
17668 }
17669 break;
17670
17671 case SPRITEMAXNPC:
17672 {
17673 //No bounds check, as this is a universal function and works from NULL pointers!
17674 guys.setMax(vbound((value/10000),1,MAX_NPC_SPRITES));
17675 break;
17676 }
17677
17678 case NPCY:
17679 {
17680
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 1041350 times.
1041414 if(GuyH::loadNPC(ri->guyref, "npc->Y") == SH::_NoError)
17681 {
17682 1041350 zfix oldy = GuyH::getNPC()->y;
17683
2/2
✓ Branch 0 taken 95921 times.
✓ Branch 1 taken 945429 times.
1041350 GuyH::getNPC()->y = get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000);
17684
2/2
✓ Branch 0 taken 95921 times.
✓ Branch 1 taken 945429 times.
1041350 GuyH::getNPC()->floor_y += ((get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000)) - oldy);
17685
17686
1/2
✓ Branch 0 taken 1041350 times.
✗ Branch 1 not taken.
1041350 if(GuyH::hasHero())
17687 Hero.setYfix(get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000));
17688 1041350 }
17689 }
17690 1041414 break;
17691
17692 case NPCZ:
17693 {
17694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 969235 times.
969235 if(GuyH::loadNPC(ri->guyref, "npc->Z") == SH::_NoError)
17695 {
17696
2/2
✓ Branch 0 taken 1114 times.
✓ Branch 1 taken 968121 times.
969235 if(!never_in_air(GuyH::getNPC()->id))
17697 {
17698
1/2
✓ Branch 0 taken 968121 times.
✗ Branch 1 not taken.
968121 if(value < 0)
17699 GuyH::getNPC()->z = zfix(0);
17700 else
17701
2/2
✓ Branch 0 taken 95728 times.
✓ Branch 1 taken 872393 times.
968121 GuyH::getNPC()->z = get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000);
17702
17703
1/2
✓ Branch 0 taken 968121 times.
✗ Branch 1 not taken.
968121 if(GuyH::hasHero())
17704 Hero.setZfix(get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000));
17705 968121 }
17706 969235 }
17707 }
17708 969235 break;
17709
17710 case NPCJUMP:
17711 {
17712
2/2
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 972076 times.
972500 if(GuyH::loadNPC(ri->guyref, "npc->Jump") == SH::_NoError)
17713 {
17714
2/2
✓ Branch 0 taken 56049 times.
✓ Branch 1 taken 916027 times.
972076 if(canfall(GuyH::getNPC()->id))
17715 916027 GuyH::getNPC()->fall =zslongToFix(value)*-100;
17716
17717
1/2
✓ Branch 0 taken 972076 times.
✗ Branch 1 not taken.
972076 if(GuyH::hasHero())
17718 Hero.setFall(zslongToFix(value)*-100);
17719 972076 }
17720 }
17721 972500 break;
17722
17723 case NPCFAKEJUMP:
17724 {
17725 if(GuyH::loadNPC(ri->guyref, "npc->FakeJump") == SH::_NoError)
17726 {
17727 if(canfall(GuyH::getNPC()->id))
17728 GuyH::getNPC()->fakefall =zslongToFix(value)*-100;
17729
17730 if(GuyH::hasHero())
17731 Hero.setFakeFall(zslongToFix(value)*-100);
17732 }
17733 }
17734 break;
17735
17736 case NPCSTEP:
17737 {
17738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
71 if(GuyH::loadNPC(ri->guyref, "npc->Step") == SH::_NoError)
17739 {
17740
2/4
✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 71 times.
✗ Branch 3 not taken.
71 if ( get_qr(qr_STEP_IS_FLOAT) || replay_is_active() )
17741 {
17742 71 GuyH::getNPC()->step = zslongToFix(value / 100);
17743 71 }
17744 else
17745 {
17746 //old, buggy code replication, round two: Go! -Z
17747 //zfix val = zslongToFix(value);
17748 //val.doFloor();
17749 //GuyH::getNPC()->step = ((val / 100.0).getFloat());
17750
17751 //old, buggy code replication, round THREE: Go! -Z
17752 GuyH::getNPC()->step = ((value/10000)/100.0);
17753 }
17754 71 }
17755 }
17756 71 break;
17757
17758 case NPCGRAVITY:
17759 {
17760 if(GuyH::loadNPC(ri->guyref, "npc->Gravity") == SH::_NoError)
17761 {
17762 if(value)
17763 GuyH::getNPC()->moveflags |= FLAG_OBEYS_GRAV;
17764 else
17765 GuyH::getNPC()->moveflags &= ~FLAG_OBEYS_GRAV;
17766 }
17767 }
17768 break;
17769
17770 case NPCXOFS:
17771 {
17772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21219 times.
21219 if(GuyH::loadNPC(ri->guyref, "npc->DrawXOffset") == SH::_NoError)
17773 21219 GuyH::getNPC()->xofs = zfix(value / 10000);
17774 }
17775 21219 break;
17776
17777 case NPCYOFS:
17778 {
17779
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28037 times.
28037 if(GuyH::loadNPC(ri->guyref, "npc->DrawYOffset") == SH::_NoError)
17780
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28037 times.
28037 GuyH::getNPC()->yofs = zfix(value / 10000) + (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
17781 }
17782 28037 break;
17783
17784 case NPCSHADOWXOFS:
17785 {
17786 if(GuyH::loadNPC(ri->guyref, "npc->ShadowXOffset") == SH::_NoError)
17787 GuyH::getNPC()->shadowxofs = zfix(value / 10000);
17788 }
17789 break;
17790
17791 case NPCSHADOWYOFS:
17792 {
17793 if(GuyH::loadNPC(ri->guyref, "npc->ShadowYOffset") == SH::_NoError)
17794 GuyH::getNPC()->shadowyofs = zfix(value / 10000);
17795 }
17796 break;
17797
17798 case NPCTOTALDYOFFS:
17799 break; //READ-ONLY
17800
17801 case NPCROTATION:
17802 {
17803 if ( get_qr(qr_OLDSPRITEDRAWS) )
17804 {
17805 Z_scripterrlog("To use %s you must disable the quest rule 'Old (Faster) Sprite Drawing'.\n",
17806 "npc->Rotation");
17807 break;
17808 }
17809 if(GuyH::loadNPC(ri->guyref, "npc->Rotation") == SH::_NoError)
17810 GuyH::getNPC()->rotation = (value / 10000);
17811 }
17812 break;
17813
17814 case NPCZOFS:
17815 {
17816 if(GuyH::loadNPC(ri->guyref, "npc->DrawZOffset") == SH::_NoError)
17817 GuyH::getNPC()->zofs = zfix(value / 10000);
17818 }
17819 break;
17820
17821 #define SET_NPC_VAR_INT(member, str) \
17822 { \
17823 if(GuyH::loadNPC(ri->guyref, str) == SH::_NoError) \
17824 GuyH::getNPC()->member = value / 10000; \
17825 }
17826
17827
17828 case NPCISCORE:
17829 if(GuyH::loadNPC(ri->guyref, "npc->isCore") == SH::_NoError)
17830 GuyH::getNPC()->isCore = ( (value / 10000) ? true : false );
17831 break;
17832
17833
17834 case NPCDIR:
17835
2/2
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 1045176 times.
1045600 SET_NPC_VAR_INT(dir, "npc->Dir") break;
17836
17837 case NPCHITDIR:
17838 if(GuyH::loadNPC(ri->guyref, "npc->HitDir") != SH::_NoError)
17839 (GuyH::getNPC()->hitdir) = vbound(value/10000, 0, 3);
17840
17841 break;
17842
17843 case NPCSLIDECLK:
17844 if(GuyH::loadNPC(ri->guyref, "npc->SlideClock") != SH::_NoError)
17845 GuyH::getNPC()->sclk = value/10000;//vbound(value/10000,0,255);
17846
17847 break;
17848
17849 case NPCFADING:
17850 if(GuyH::loadNPC(ri->guyref, "npc->Fading") != SH::_NoError)
17851 (GuyH::getNPC()->fading) = vbound(value/10000,0,4);
17852
17853 break;
17854
17855 case NPCHALTCLK:
17856 if(GuyH::loadNPC(ri->guyref, "npc->Halt") != SH::_NoError)
17857 (GuyH::getNPC()->clk2) = vbound(value/10000,0,214748);
17858
17859 break;
17860
17861 case NPCFRAME:
17862 if(GuyH::loadNPC(ri->guyref, "npc->Frame") != SH::_NoError)
17863 (GuyH::getNPC()->clk2) = vbound(value/10000,0,214748);
17864
17865 break;
17866
17867 case NPCMOVESTATUS:
17868 if(GuyH::loadNPC(ri->guyref, "npc->MoveStatus") != SH::_NoError)
17869 (GuyH::getNPC()->movestatus) = vbound(value/10000,0,3);
17870
17871 break;
17872
17873 case NPCRATE:
17874 SET_NPC_VAR_INT(rate, "npc->Rate") break;
17875
17876 case NPCHOMING:
17877 SET_NPC_VAR_INT(homing, "npc->Homing") break;
17878
17879 case NPCFRAMERATE:
17880 SET_NPC_VAR_INT(frate, "npc->ASpeed") break;
17881
17882 case NPCHALTRATE:
17883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 SET_NPC_VAR_INT(hrate, "npc->HaltRate") break;
17884
17885 case NPCRANDOM:
17886 SET_NPC_VAR_INT(rate, "npc->Random") break;
17887
17888 case NPCDRAWTYPE:
17889
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4414 times.
4414 SET_NPC_VAR_INT(drawstyle, "npc->DrawStyle") break;
17890
17891 case NPCHP:
17892
2/2
✓ Branch 0 taken 425 times.
✓ Branch 1 taken 1032467 times.
1032892 SET_NPC_VAR_INT(hp, "npc->HP") break;
17893
17894 case NPCORIGINALHP:
17895 SET_NPC_VAR_INT(starting_hp, "npc->OriginalHP") break;
17896
17897 //case NPCID: SET_NPC_VAR_INT(id, "npc->ID") break; ~Disallowed
17898 case NPCDP:
17899
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 784 times.
788 SET_NPC_VAR_INT(dp, "npc->Damage") break;
17900
17901 case NPCTYPE:
17902 {
17903 SET_NPC_VAR_INT(family, "npc->Type") break;
17904 }
17905
17906 case NPCWDP:
17907
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 317 times.
321 SET_NPC_VAR_INT(wdp, "npc->WeaponDamage") break;
17908
17909 case NPCITEMSET:
17910
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 SET_NPC_VAR_INT(item_set, "npc->ItemSet") break;
17911
17912 case NPCBOSSPAL:
17913 SET_NPC_VAR_INT(bosspal, "npc->BossPal") break;
17914
17915 case NPCBGSFX:
17916
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(GuyH::loadNPC(ri->guyref, "npc->SFX") == SH::_NoError)
17917 {
17918 13 enemy *en=GuyH::getNPC();
17919 13 int32_t newSFX = value / 10000;
17920
17921 // Stop the old sound and start the new one
17922
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2 times.
13 if(en->bgsfx != newSFX)
17923 {
17924 2 en->stop_bgsfx(GuyH::getNPCIndex(ri->guyref));
17925 2 cont_sfx(newSFX);
17926 2 en->bgsfx = newSFX;
17927 2 }
17928 13 }
17929 13 break;
17930
17931
17932 case NPCEXTEND:
17933
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77610 times.
77610 SET_NPC_VAR_INT(extend, "npc->Extend") break;
17934
17935 case NPCHXOFS:
17936
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 749 times.
1181 SET_NPC_VAR_INT(hxofs, "npc->HitXOffset") break;
17937
17938 case NPCHYOFS:
17939
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 3751 times.
4183 SET_NPC_VAR_INT(hyofs, "npc->HitYOffset") break;
17940
17941 case NPCHXSZ:
17942
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 6635 times.
7067 SET_NPC_VAR_INT(hit_width, "npc->HitWidth") break;
17943
17944 case NPCHYSZ:
17945
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 6635 times.
7067 SET_NPC_VAR_INT(hit_height, "npc->HitHeight") break;
17946
17947 case NPCHZSZ:
17948
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 SET_NPC_VAR_INT(hzsz, "npc->HitZHeight") break;
17949
17950 case NPCCOLLDET:
17951
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 28754 times.
28758 SET_NPC_VAR_INT(scriptcoldet, "npc->CollDetection") break;
17952
17953 case NPCENGINEANIMATE:
17954 SET_NPC_VAR_INT(do_animation, "npc->Animation") break;
17955
17956 case NPCSTUN:
17957
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1094 times.
1094 SET_NPC_VAR_INT(stunclk, "npc->Stun") break;
17958
17959 case NPCHUNGER:
17960 SET_NPC_VAR_INT(grumble, "npc->Hunger") break;
17961
17962 case NPCWEAPSPRITE:
17963 SET_NPC_VAR_INT(wpnsprite, "npc->WeaponSprite") break;
17964
17965 case NPCCSET:
17966 {
17967
2/2
✓ Branch 0 taken 435 times.
✓ Branch 1 taken 1018836 times.
1019271 if(GuyH::loadNPC(ri->guyref, "npc->CSet") == SH::_NoError)
17968 {
17969 1018836 GuyH::getNPC()->cs = (value / 10000) & 0xF;
17970
1/2
✓ Branch 0 taken 1018836 times.
✗ Branch 1 not taken.
1018836 if(GuyH::getNPC()->family == eeLEV) GuyH::getNPC()->dcset = (value / 10000) & 0xF;
17971 1018836 }
17972 }
17973 1019271 break;
17974
17975 //Bounds on value
17976 case NPCTXSZ:
17977 {
17978 10538 int32_t height = value / 10000;
17979
17980
3/4
✓ Branch 0 taken 10102 times.
✓ Branch 1 taken 436 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10102 times.
10538 if(GuyH::loadNPC(ri->guyref, "npc->TileWidth") == SH::_NoError &&
17981 10102 BC::checkBounds(height, 0, 20, "npc->TileWidth") == SH::_NoError)
17982 10102 GuyH::getNPC()->txsz = height;
17983 }
17984 10538 break;
17985
17986 case NPCTYSZ:
17987 {
17988 10538 int32_t width = value / 10000;
17989
17990
3/4
✓ Branch 0 taken 10102 times.
✓ Branch 1 taken 436 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10102 times.
10538 if(GuyH::loadNPC(ri->guyref, "npc->TileHeight") == SH::_NoError &&
17991 10102 BC::checkBounds(width, 0, 20, "npc->TileHeight") == SH::_NoError)
17992 10102 GuyH::getNPC()->tysz = width;
17993 }
17994 10538 break;
17995
17996 case NPCOTILE:
17997 {
17998 8695 int32_t tile = value / 10000;
17999
18000
3/4
✓ Branch 0 taken 8688 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8688 times.
8695 if(GuyH::loadNPC(ri->guyref, "npc->OriginalTile") == SH::_NoError &&
18001 8688 BC::checkTile(tile, "npc->OriginalTile") == SH::_NoError)
18002 8688 GuyH::getNPC()->o_tile = tile;
18003 }
18004 8695 break;
18005
18006 case NPCTILE:
18007 {
18008 4911 int32_t tile = value / 10000;
18009
18010
2/4
✓ Branch 0 taken 4911 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4911 times.
4911 if(GuyH::loadNPC(ri->guyref, "npc->Tile") == SH::_NoError &&
18011 4911 BC::checkTile(tile, "npc->Tile") == SH::_NoError)
18012 4911 GuyH::getNPC()->tile = tile;
18013 }
18014 4911 break;
18015
18016 case NPCSCRIPTTILE:
18017 {
18018 if(GuyH::loadNPC(ri->guyref, "npc->ScriptTile") == SH::_NoError)
18019 GuyH::getNPC()->scripttile = vbound((value/10000),-1, NEWMAXTILES-1);
18020 }
18021 break;
18022
18023 case NPCSCRIPTFLIP:
18024 {
18025 if(GuyH::loadNPC(ri->guyref, "npc->ScriptFlip") == SH::_NoError )
18026 GuyH::getNPC()->scriptflip = vbound(value/10000, -1, 127);
18027 }
18028 break;
18029
18030 case NPCWEAPON:
18031 {
18032 int32_t weapon = value / 10000;
18033
18034 if(GuyH::loadNPC(ri->guyref, "npc->Weapon") == SH::_NoError &&
18035 BC::checkBounds(weapon, 0, MAXWPNS-1, "npc->Weapon") == SH::_NoError)
18036 {
18037 GuyH::getNPC()->wpn = weapon;
18038
18039 //al_trace("Correct weapon sprite is: %d /n", FFCore.GetDefaultWeaponSprite(weapon));
18040 if ( get_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE) ) //this should probably just be an extra_rule
18041 {
18042 GuyH::getNPC()->wpnsprite = FFCore.GetDefaultWeaponSprite(weapon);
18043 }
18044 //else GuyH::getNPC()->wpnsprite = FFCore.GetDefaultWeaponSprite(weapon); //just to test that this works.
18045 }
18046 }
18047 break;
18048
18049 //Indexed
18050 case NPCDEFENSED:
18051 {
18052 545362 int32_t a = ri->d[rINDEX] / 10000;
18053
18054
2/4
✓ Branch 0 taken 545362 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 545362 times.
545362 if(GuyH::loadNPC(ri->guyref, "npc->Defense") == SH::_NoError &&
18055 545362 BC::checkBounds(a, 0, (edefLAST255), "npc->Defense") == SH::_NoError)
18056 {
18057
4/4
✓ Branch 0 taken 545278 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 521697 times.
✓ Branch 3 taken 23581 times.
545362 if ( ( get_qr(qr_250WRITEEDEFSCRIPT) ) && a == edefSCRIPT )
18058 {
18059
2/2
✓ Branch 0 taken 235810 times.
✓ Branch 1 taken 23581 times.
259391 for ( int32_t sd = edefSCRIPT01; sd <= edefSCRIPT10; sd++ )
18060 {
18061 235810 GuyH::getNPC()->defense[sd] = vbound((value / 10000),0,255);
18062 235810 }
18063 23581 }
18064 //no else here, is intentional as a fallthrough. -Z
18065 545362 GuyH::getNPC()->defense[a] = vbound((value / 10000),0,255);
18066 545362 }
18067 }
18068 545362 break;
18069
18070 case NPCPARENTUID:
18071 if(GuyH::loadNPC(ri->guyref, "npc->ParentUID") == SH::_NoError)
18072 {
18073 GuyH::getNPC()->parent_script_UID = value; //literal, not *10000
18074 }
18075 break;
18076
18077 case NPCHITBY:
18078 {
18079 int32_t indx = ri->d[rINDEX] / 10000;
18080
18081 if(GuyH::loadNPC(ri->guyref, "npc->HitBy[]") == SH::_NoError)
18082 {
18083 switch(indx)
18084 {
18085 //screen index objects
18086 case 0:
18087 case 1:
18088 case 2:
18089 case 3:
18090 case 8:
18091 case 9:
18092 case 10:
18093 case 11:
18094 case 12:
18095 case 16:
18096 {
18097 GuyH::getNPC()->hitby[indx] = vbound((value / 10000),0,255); //Once again, why did I vbound this, and why did I allow it to be written? UIDs are LONGs, with a starting value of 0.0001. -Z
18098 break;
18099 }
18100 //UIDs
18101 case 4:
18102 case 5:
18103 case 6:
18104 case 7:
18105 case 13:
18106 case 14:
18107 case 15:
18108 {
18109 GuyH::getNPC()->hitby[indx] = value; //Once again, why did I vbound this, and why did I allow it to be written? UIDs are LONGs, with a starting value of 0.0001. -Z
18110 break;
18111 }
18112 default: al_trace("Invalid index used with npc->hitBy[%d]. /n", indx); break;
18113 }
18114 }
18115 break;
18116 }
18117
18118 //2.future compat. -Z
18119
18120
18121 case NPCSCRDEFENSED:
18122 {
18123 int32_t a = ri->d[rINDEX] / 10000;
18124
18125 if(GuyH::loadNPC(ri->guyref, "npc->ScriptDefense") == SH::_NoError &&
18126 BC::checkBounds(a, 0, edefSCRIPTDEFS_MAX, "npc->ScriptDefense") == SH::_NoError)
18127 GuyH::getNPC()->defense[a+edefSCRIPT01] = value / 10000;
18128 }
18129 break;
18130
18131 case NPCMISCD:
18132 {
18133 2612168 int32_t a = ri->d[rINDEX] / 10000;
18134
18135
3/4
✓ Branch 0 taken 2612129 times.
✓ Branch 1 taken 39 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2612129 times.
2612168 if(GuyH::loadNPC(ri->guyref, "npc->Misc") == SH::_NoError &&
18136 2612129 BC::checkMisc32(a, "npc->Misc") == SH::_NoError)
18137 2612129 GuyH::getNPC()->miscellaneous[a] = value;
18138
18139 }
18140
18141 2612168 break;
18142
18143 case NPCINITD:
18144 {
18145 int32_t a = ri->d[rINDEX] / 10000;
18146
18147 if(GuyH::loadNPC(ri->guyref, "npc->InitD[]") == SH::_NoError)
18148 {
18149 //enemy *e = (enemy*)guys.spr(ri->guyref);
18150 //e->initD[a] = value;
18151 GuyH::getNPC()->initD[a] = value;
18152 }
18153 }
18154 break;
18155
18156 case NPCSCRIPT:
18157 {
18158 if(GuyH::loadNPC(ri->guyref, "npc->Script") == SH::_NoError)
18159 {
18160 FFScript::deallocateAllArrays(ScriptType::NPC, ri->guyref);
18161 //enemy *e = (enemy*)guys.spr(ri->guyref);
18162 //e->initD[a] = value;
18163 if ( get_qr(qr_CLEARINITDONSCRIPTCHANGE))
18164 {
18165 for(int32_t q=0; q<8; q++)
18166 GuyH::getNPC()->initD[q] = 0;
18167 }
18168 GuyH::getNPC()->script = vbound((value/10000), 0, NUMSCRIPTGUYS-1);
18169 }
18170 }
18171 break;
18172
18173 //npc->Attributes[] setter -Z
18174 case NPCDD:
18175 {
18176 int32_t a = ri->d[rINDEX] / 10000;
18177
18178 if(GuyH::loadNPC(ri->guyref, "npc->Attributes") == SH::_NoError &&
18179 BC::checkBounds(a, 0, 31, "npc->Attributes") == SH::_NoError)
18180
18181 switch(a)
18182 {
18183 case 0: GuyH::getNPC()->dmisc1 = value / 10000; break;
18184 case 1: GuyH::getNPC()->dmisc2 = value / 10000; break;
18185 case 2: GuyH::getNPC()->dmisc3 = value / 10000; break;
18186 case 3: GuyH::getNPC()->dmisc4 = value / 10000; break;
18187 case 4: GuyH::getNPC()->dmisc5 = value / 10000; break;
18188 case 5: GuyH::getNPC()->dmisc6 = value / 10000; break;
18189 case 6: GuyH::getNPC()->dmisc7 = value / 10000; break;
18190 case 7: GuyH::getNPC()->dmisc8 = value / 10000; break;
18191 case 8: GuyH::getNPC()->dmisc9 = value / 10000; break;
18192 case 9: GuyH::getNPC()->dmisc10 = value / 10000; break;
18193 case 10: GuyH::getNPC()->dmisc11 = value / 10000; break;
18194 case 11: GuyH::getNPC()->dmisc12 = value / 10000; break;
18195 case 12: GuyH::getNPC()->dmisc13 = value / 10000; break;
18196 case 13: GuyH::getNPC()->dmisc14 = value / 10000; break;
18197 case 14: GuyH::getNPC()->dmisc15 = value / 10000; break;
18198 case 15: GuyH::getNPC()->dmisc16 = value / 10000; break;
18199 case 16: GuyH::getNPC()->dmisc17 = value / 10000; break;
18200 case 17: GuyH::getNPC()->dmisc18 = value / 10000; break;
18201 case 18: GuyH::getNPC()->dmisc19 = value / 10000; break;
18202 case 19: GuyH::getNPC()->dmisc20 = value / 10000; break;
18203 case 20: GuyH::getNPC()->dmisc21 = value / 10000; break;
18204 case 21: GuyH::getNPC()->dmisc22 = value / 10000; break;
18205 case 22: GuyH::getNPC()->dmisc23 = value / 10000; break;
18206 case 23: GuyH::getNPC()->dmisc24 = value / 10000; break;
18207 case 24: GuyH::getNPC()->dmisc25 = value / 10000; break;
18208 case 25: GuyH::getNPC()->dmisc26 = value / 10000; break;
18209 case 26: GuyH::getNPC()->dmisc27 = value / 10000; break;
18210 case 27: GuyH::getNPC()->dmisc28 = value / 10000; break;
18211 case 28: GuyH::getNPC()->dmisc28 = value / 10000; break;
18212 case 29: GuyH::getNPC()->dmisc30 = value / 10000; break;
18213 case 30: GuyH::getNPC()->dmisc31 = value / 10000; break;
18214 case 31: GuyH::getNPC()->dmisc32 = value / 10000; break;
18215 default: break;
18216 }
18217 break;
18218 }
18219
18220
18221 case NPCINVINC:
18222 {
18223 if(GuyH::loadNPC(ri->guyref, "npc->InvFrames") == SH::_NoError)
18224 GuyH::getNPC()->hclk = (int32_t)value/10000;
18225 }
18226 break;
18227
18228 case NPCSUPERMAN:
18229 {
18230 if(GuyH::loadNPC(ri->guyref, "npc->Invincible") == SH::_NoError)
18231 GuyH::getNPC()->superman = (int32_t)value/10000;
18232 }
18233 break;
18234
18235 case NPCHASITEM:
18236 {
18237 if(GuyH::loadNPC(ri->guyref, "npc->HasItem") == SH::_NoError)
18238 GuyH::getNPC()->itemguy = (value/10000)?1:0;
18239 }
18240 break;
18241
18242 case NPCRINGLEAD:
18243 {
18244 if(GuyH::loadNPC(ri->guyref, "npc->Ringleader") == SH::_NoError)
18245 GuyH::getNPC()->leader = (value/10000)?1:0;
18246 }
18247 break;
18248
18249 case NPCSHIELD:
18250 {
18251 int32_t indx = ri->d[rINDEX];
18252 if(GuyH::loadNPC(ri->guyref, "npc->Shield[]") == SH::_NoError)
18253 {
18254 switch(indx)
18255 {
18256 case 0:
18257 {
18258 (ri->d[rINDEX2])? (GuyH::getNPC()->flags |= inv_front) : (GuyH::getNPC()->flags &= ~inv_front);
18259 break;
18260 }
18261 case 1:
18262 {
18263 (ri->d[rINDEX2])? (GuyH::getNPC()->flags |= inv_left) : (GuyH::getNPC()->flags &= ~inv_left);
18264 break;
18265 }
18266 case 2:
18267 {
18268 (ri->d[rINDEX2])? (GuyH::getNPC()->flags |= inv_right) : (GuyH::getNPC()->flags &= ~inv_right);
18269 break;
18270 }
18271 case 3:
18272 {
18273 (ri->d[rINDEX2])? (GuyH::getNPC()->flags |= inv_back) : (GuyH::getNPC()->flags &= ~inv_back);
18274 break;
18275 }
18276 case 4: //shield can be broken
18277 {
18278 (ri->d[rINDEX2])? (GuyH::getNPC()->flags |= guy_bkshield) : (GuyH::getNPC()->flags &= ~guy_bkshield);
18279 break;
18280 }
18281 default:
18282 {
18283 Z_scripterrlog("Invalid Array Index passed to npc->Shield[]: %d\n", indx);
18284 break;
18285 }
18286 }
18287 }
18288 }
18289 break;
18290
18291 case NPCFROZENTILE:
18292 SET_NPC_VAR_INT(frozentile, "npc->FrozenTile"); break;
18293 case NPCFROZENCSET:
18294 SET_NPC_VAR_INT(frozencset, "npc->FrozenCSet"); break;
18295 case NPCFROZEN:
18296 SET_NPC_VAR_INT(frozenclock, "npc->Frozen"); break;
18297
18298 case NPCBEHAVIOUR:
18299 {
18300 if(GuyH::loadNPC(ri->guyref, "npc->Behaviour[]") != SH::_NoError)
18301 {
18302 break;
18303 }
18304 int32_t index = vbound(ri->d[rINDEX]/10000,0,4);
18305 switch(index)
18306 {
18307 case 0:
18308 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG1 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG1;
18309 break;
18310 case 1:
18311 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG2 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG2;
18312 break;
18313 case 2:
18314 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG3 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG3;
18315 break;
18316 case 3:
18317 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG4 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG4;
18318 break;
18319 case 4:
18320 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG5 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG5;
18321 break;
18322 case 5:
18323 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG6 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG6;
18324 break;
18325 case 6:
18326 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG7 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG7;
18327 break;
18328 case 7:
18329 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG8 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG8;
18330 break;
18331 case 8:
18332 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG9 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG9;
18333 break;
18334 case 9:
18335 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG10 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG10;
18336 break;
18337 case 10:
18338 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG11 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG11;
18339 break;
18340 case 11:
18341 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG12 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG12;
18342 break;
18343 case 12:
18344 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG13 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG13;
18345 break;
18346 case 13:
18347 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG14 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG14;
18348 break;
18349 case 14:
18350 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG15 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG15;
18351 break;
18352 case 15:
18353 (value) ? GuyH::getNPC()->editorflags|=ENEMY_FLAG16 : GuyH::getNPC()->editorflags&= ~ENEMY_FLAG16;
18354 break;
18355
18356
18357 default:
18358 break;
18359 }
18360
18361 break;
18362 }
18363 case NPCFALLCLK:
18364 if(GuyH::loadNPC(ri->guyref, "npc->Falling") == SH::_NoError)
18365 {
18366 if(GuyH::getNPC()->fallclk != 0 && value == 0)
18367 {
18368 GuyH::getNPC()->cs = GuyH::getNPC()->old_cset;
18369 GuyH::getNPC()->tile = GuyH::getNPC()->o_tile;
18370 }
18371 else if(GuyH::getNPC()->fallclk == 0 && value != 0) GuyH::getNPC()->old_cset = GuyH::getNPC()->cs;
18372 GuyH::getNPC()->fallclk = vbound(value/10000,0,70);
18373 }
18374 break;
18375 case NPCFALLCMB:
18376 if(GuyH::loadNPC(ri->guyref, "npc->FallCombo") == SH::_NoError)
18377 {
18378 GuyH::getNPC()->fallCombo = vbound(value/10000,0,MAXCOMBOS-1);
18379 }
18380 break;
18381 case NPCDROWNCLK:
18382 if(GuyH::loadNPC(ri->guyref, "npc->Drowning") == SH::_NoError)
18383 {
18384 if(GuyH::getNPC()->drownclk != 0 && value == 0)
18385 {
18386 GuyH::getNPC()->cs = GuyH::getNPC()->old_cset;
18387 GuyH::getNPC()->tile = GuyH::getNPC()->o_tile;
18388 }
18389 else if(GuyH::getNPC()->drownclk == 0 && value != 0) GuyH::getNPC()->old_cset = GuyH::getNPC()->cs;
18390 GuyH::getNPC()->drownclk = vbound(value/10000,0,70);
18391 }
18392 break;
18393 case NPCDROWNCMB:
18394 if(GuyH::loadNPC(ri->guyref, "npc->DrowningCombo") == SH::_NoError)
18395 {
18396 GuyH::getNPC()->drownCombo = vbound(value/10000,0,MAXCOMBOS-1);
18397 }
18398 case NPCFAKEZ:
18399 {
18400 if(GuyH::loadNPC(ri->guyref, "npc->FakeZ") == SH::_NoError)
18401 {
18402 if(!never_in_air(GuyH::getNPC()->id))
18403 {
18404 if(value < 0)
18405 GuyH::getNPC()->fakez = zfix(0);
18406 else
18407 GuyH::getNPC()->fakez = get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000);
18408
18409 if(GuyH::hasHero())
18410 Hero.setFakeZfix(get_qr(qr_SPRITEXY_IS_FLOAT) ? zslongToFix(value) : zfix(value/10000));
18411 }
18412 }
18413 }
18414 break;
18415 case NPCMOVEFLAGS:
18416 {
18417 if(GuyH::loadNPC(ri->guyref, "npc->MoveFlags[]") == SH::_NoError)
18418 {
18419 int32_t indx = ri->d[rINDEX]/10000;
18420 if(BC::checkBounds(indx, 0, 15, "npc->MoveFlags[]") == SH::_NoError)
18421 {
18422 //All bits, in order, of a single byte; just use bitwise
18423 int32_t bit = 1<<indx;
18424 if(value)
18425 GuyH::getNPC()->moveflags |= bit;
18426 else
18427 GuyH::getNPC()->moveflags &= ~bit;
18428 }
18429 }
18430 break;
18431 }
18432
18433 case NPCGLOWRAD:
18434 if(GuyH::loadNPC(ri->guyref, "npc->LightRadius") == SH::_NoError)
18435 {
18436 GuyH::getNPC()->glowRad = vbound(value/10000,0,255);
18437 }
18438 break;
18439 case NPCGLOWSHP:
18440 if(GuyH::loadNPC(ri->guyref, "npc->LightShape") == SH::_NoError)
18441 {
18442 GuyH::getNPC()->glowShape = vbound(value/10000,0,255);
18443 }
18444 break;
18445
18446 case NPCSHADOWSPR:
18447 if(GuyH::loadNPC(ri->guyref, "npc->ShadowSprite") == SH::_NoError)
18448 {
18449 GuyH::getNPC()->spr_shadow = vbound(value/10000,0,255);
18450 }
18451 break;
18452 case NPCSPAWNSPR:
18453 if(GuyH::loadNPC(ri->guyref, "npc->SpawnSprite") == SH::_NoError)
18454 {
18455 GuyH::getNPC()->spr_spawn = vbound(value/10000,0,255);
18456 }
18457 break;
18458 case NPCDEATHSPR:
18459 if(GuyH::loadNPC(ri->guyref, "npc->DeathSprite") == SH::_NoError)
18460 {
18461 GuyH::getNPC()->spr_death = vbound(value/10000,0,255);
18462 }
18463 break;
18464 case NPCSWHOOKED:
18465 break; //read-only
18466 case NPCCANFLICKER:
18467 if(GuyH::loadNPC(ri->guyref, "npc->InvFlicker") == SH::_NoError)
18468 {
18469 GuyH::getNPC()->setCanFlicker(value != 0);
18470 }
18471 break;
18472
18473
18474 ///----------------------------------------------------------------------------------------------------//
18475 //Game Information
18476
18477 case GAMEDEATHS:
18478 game->set_deaths(value/10000);
18479 break;
18480
18481 case GAMECHEAT:
18482 cheat=vbound(value/10000,0,4);
18483 if(maxcheat < cheat) maxcheat = cheat;
18484 if(cheat) game->did_cheat(true);
18485 break;
18486
18487 case GAMEMAXCHEAT:
18488 maxcheat=vbound(value/10000,0,4);
18489 game->set_cheat(maxcheat);
18490 if(cheat > maxcheat) cheat = maxcheat;
18491 break;
18492
18493 case GAMETIME:
18494 1 game->set_time(value);
18495 1 break; // Can't multiply by 10000 or the maximum result is too big
18496
18497 case ACTIVESSSPEED:
18498 Hero.subscr_speed = vbound((value/10000),1,85);
18499 break; // Can't multiply by 10000 or the maximum result is too big
18500
18501 case GAMETIMEVALID:
18502 game->set_timevalid((value/10000)?1:0);
18503 break;
18504
18505 case GAMEHASPLAYED:
18506 game->set_hasplayed((value/10000)?1:0);
18507 break;
18508
18509 case TYPINGMODE:
18510 FFCore.kb_typing_mode = ((value/10000)?true:false);
18511 break;
18512
18513 case SKIPCREDITS:
18514 FFCore.skip_ending_credits = ((value/10000)?true:false);
18515 break;
18516
18517 case SKIPF6:
18518 set_qr(qr_NOCONTINUE,((value/10000)?1:0));
18519 break;
18520
18521
18522
18523 case GAMEGUYCOUNT:
18524 {
18525 26 int32_t mi2 = (currmap*MAPSCRSNORMAL)+(ri->d[rINDEX]/10000);
18526 26 game->guys[mi2]=value/10000;
18527 }
18528 26 break;
18529
18530 case GAMECONTSCR:
18531 88964 game->set_continue_scrn(value/10000);
18532 88964 break;
18533
18534 case GAMECONTDMAP:
18535 88964 game->set_continue_dmap(value/10000);
18536 88964 break;
18537
18538 case GAMEENTRSCR:
18539 88970 lastentrance=value/10000;
18540 88970 break;
18541
18542 case GAMEENTRDMAP:
18543 88970 lastentrance_dmap=value/10000;
18544 88970 break;
18545
18546 case GAMECOUNTERD:
18547 2705905 game->set_counter(value/10000, (ri->d[rINDEX])/10000);
18548 2705905 break;
18549
18550 case GAMEMCOUNTERD:
18551 551 game->set_maxcounter(value/10000, (ri->d[rINDEX])/10000);
18552 551 break;
18553
18554 case GAMEDCOUNTERD:
18555 8 game->set_dcounter(value/10000, (ri->d[rINDEX])/10000);
18556 8 break;
18557
18558 case GAMEGENERICD:
18559 game->set_generic(value/10000, (ri->d[rINDEX])/10000);
18560 break;
18561 case GAMEMISC:
18562 {
18563 int32_t indx = ri->d[rINDEX]/10000;
18564 if ( indx < 0 || indx > 31 )
18565 {
18566 Z_scripterrlog("Invalid index used to access Game->Misc: %d\n", indx);
18567 }
18568 else
18569 {
18570 QMisc.questmisc[indx] = (value/((get_qr(qr_OLDQUESTMISC)) ? 10000 : 1));
18571 }
18572 break;
18573 }
18574 case GAMEITEMSD:
18575 game->set_item((ri->d[rINDEX])/10000,(value!=0));
18576 break;
18577
18578 case DISABLEDITEM:
18579 {
18580 int id = (ri->d[rINDEX])/10000;
18581 if(unsigned(id) >= MAXITEMS)
18582 break;
18583 game->items_off[id]=value/10000;
18584 removeFromItemCache(itemsbuf[id].family);
18585 break;
18586 }
18587
18588 case GAMESUSPEND:
18589 {
18590 131 int32_t inx = (ri->d[rINDEX])/10000;
18591
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 if ( (unsigned) inx > (susptLAST-1) )
18592 {
18593 Z_scripterrlog("Invalid array index [%d] passed to Gme->Suspend[]\n");
18594 }
18595 131 FFCore.system_suspend[inx]= ( (value) ? 1 : 0 );
18596 131 break;
18597 }
18598
18599 case GAMELITEMSD:
18600 64 game->lvlitems[(ri->d[rINDEX])/10000]=value/10000;
18601 64 break;
18602 case GAMELSWITCH:
18603 {
18604 int32_t ind = (ri->d[rINDEX])/10000;
18605 if(unsigned(ind) < MAXLEVELS)
18606 game->lvlswitches[ind]=value;
18607 break;
18608 }
18609 case GAMEGSWITCH:
18610 {
18611 int32_t ind = (ri->d[rINDEX])/10000;
18612 if(unsigned(ind) < NUM_GSWITCHES)
18613 game->gswitch_timers[ind]=value/10000;
18614 break;
18615 }
18616 case GAMEBOTTLEST:
18617 game->set_bottle_slot((ri->d[rINDEX])/10000,value/10000);
18618 break;
18619
18620 case TANGOARR:
18621 {
18622 int32_t inx = (ri->d[rINDEX])/10000;
18623 if ( ((unsigned)inx) > 255 )
18624 {
18625 Z_scripterrlog("Invalid index %d supplied to Game->Tango[].\n", inx);
18626 break;
18627 }
18628 else
18629 {
18630 FFCore.TangoArray[inx]=value/10000;
18631 break;
18632 }
18633 }
18634
18635 case GHOSTARR:
18636 {
18637 int32_t inx = (ri->d[rINDEX])/10000;
18638 if ( ((unsigned)inx) > 255 )
18639 {
18640 Z_scripterrlog("Invalid index %d supplied to Game->Ghost[].\n", inx);
18641 break;
18642 }
18643 else
18644 {
18645
18646 FFCore.GhostArray[inx]=value/10000;;
18647 break;
18648 }
18649 }
18650 case STDARR:
18651 {
18652 int32_t inx = (ri->d[rINDEX])/10000;
18653 if ( ((unsigned)inx) > 255 )
18654 {
18655 Z_scripterrlog("Invalid index %d supplied to Game->STD[].\n", inx);
18656 break;
18657 }
18658 else
18659 {
18660 FFCore.StdArray[inx]=value/10000;
18661 break;
18662 }
18663 }
18664
18665 case GAMEMISCSPR:
18666 {
18667 int32_t inx = (ri->d[rINDEX])/10000;
18668 if ( ((unsigned)inx) > sprMAX )
18669 {
18670 Z_scripterrlog("Invalid index %d supplied to Game->MiscSprites[].\n", inx);
18671 }
18672 else
18673 {
18674 QMisc.sprites[inx] = vbound(value/10000, 0, 255);
18675 }
18676 break;
18677 }
18678 case GAMEMISCSFX:
18679 {
18680 int32_t inx = (ri->d[rINDEX])/10000;
18681 if ( ((unsigned)inx) > sfxMAX )
18682 {
18683 Z_scripterrlog("Invalid index %d supplied to Game->MiscSFX[].\n", inx);
18684 }
18685 else
18686 {
18687 QMisc.miscsfx[inx] = vbound(value/10000, 0, 255);
18688 }
18689 break;
18690 }
18691 case GAMEEVENTDATA:
18692 {
18693 int32_t inx = (ri->d[rINDEX])/10000;
18694 if ( ((unsigned)inx) < FFCore.eventData.size() )
18695 {
18696 FFCore.eventData[inx] = value;
18697 }
18698 break;
18699 }
18700 case GAMEMOUSECURSOR:
18701 {
18702 int v = value/10000;
18703 if(v < 0 || v >= ZCM_MAX)
18704 break;
18705 game_mouse_index = v;
18706 game_mouse();
18707 break;
18708 }
18709 case GAMETRIGGROUPS:
18710 break; //read-only
18711
18712 case GAMELKEYSD:
18713 3 game->lvlkeys[(ri->d[rINDEX])/10000]=value/10000;
18714 3 break;
18715
18716 case GAMEGRAVITY:
18717 {
18718 int32_t indx = ri->d[rINDEX]/10000;
18719 if(indx < 0 || indx > 2)
18720 {
18721 Z_scripterrlog("Invalid index used to access Game->Gravity[]: %d\n", indx);
18722 }
18723 else
18724 {
18725 switch(indx)
18726 {
18727 case 0: //Gravity Strength
18728 zinit.gravity2 = value;
18729 break;
18730 case 1: //Terminal Velocity
18731 zinit.terminalv = value / 100;
18732 break;
18733 case 2: //Sprite Layer Threshold
18734 zinit.jump_hero_layer_threshold = value / 10000;
18735 break;
18736 }
18737 }
18738 break;
18739 }
18740
18741 case SCREENSTATED:
18742 {
18743 394 int32_t mi2 = (currmap*MAPSCRSNORMAL)+currscr;
18744
2/2
✓ Branch 0 taken 390 times.
✓ Branch 1 taken 4 times.
394 (value)?setmapflag(mi2, 1<<((ri->d[rINDEX])/10000)) : unsetmapflag(mi2, 1 << ((ri->d[rINDEX]) / 10000));
18745 }
18746 394 break;
18747 case SCREENEXSTATED:
18748 {
18749 int32_t mi2 = (currmap*MAPSCRSNORMAL)+currscr;
18750 (value)?setxmapflag(mi2, 1<<((ri->d[rINDEX])/10000)) : unsetxmapflag(mi2, 1 << ((ri->d[rINDEX]) / 10000));
18751 }
18752 break;
18753 case SCREENLENSSHOWS:
18754 {
18755 int ind = ri->d[rINDEX]/10000;
18756 if(ind < 0 || ind > 6)
18757 Z_scripterrlog("Bad index Screen->LensShows[%d]\n",ind);
18758 else
18759 {
18760 SETFLAG(tmpscr->lens_show, 1<<ind, value);
18761 if(value) tmpscr->lens_hide &= ~(1<<ind);
18762 }
18763 break;
18764 }
18765 case SCREENLENSHIDES:
18766 {
18767 int ind = ri->d[rINDEX]/10000;
18768 if(ind < 0 || ind > 6)
18769 Z_scripterrlog("Bad index Screen->LensHides[%d]\n",ind);
18770 else
18771 {
18772 SETFLAG(tmpscr->lens_hide, 1<<ind, value);
18773 if(value) tmpscr->lens_show &= ~(1<<ind);
18774 }
18775 break;
18776 }
18777
18778 case SCREENSTATEDD:
18779 {
18780 649 int32_t mi2 = ri->d[rINDEX]/10000;
18781 649 mi2 -= 8*(mi2/MAPSCRS);
18782
18783
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 649 times.
649 if(BC::checkMapID(mi2>>7, "Game->SetScreenState") == SH::_NoError)
18784
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 455 times.
649 (value)?setmapflag(mi2, 1<<(ri->d[rINDEX2]/10000)) : unsetmapflag(mi2, 1 << (ri->d[rINDEX2] / 10000), true);
18785 }
18786 649 break;
18787
18788 case GAMEGUYCOUNTD:
18789 game->guys[(currmap*MAPSCRSNORMAL)+(ri->d[rINDEX]/10000)] = value / 10000;
18790 break;
18791
18792 case GAMECLICKFREEZE:
18793 disableClickToFreeze=value==0;
18794 break;
18795
18796
18797 case NOACTIVESUBSC:
18798 Hero.stopSubscreenFalling((value/10000)?1:0);
18799 break;
18800
18801 ///----------------------------------------------------------------------------------------------------//
18802 //BottleTypes
18803 case BOTTLECOUNTER:
18804 {
18805 if(bottletype* ptr = checkBottleData(ri->bottletyperef, "Counter[]"))
18806 {
18807 int32_t indx = ri->d[rINDEX]/10000;
18808 int32_t ctr = vbound(value/10000, -1, MAX_COUNTERS-1);
18809 if(unsigned(indx) > 2)
18810 {
18811 Z_scripterrlog("Invalid index %d supplied to bottledata->Counter[].\n", indx);
18812 break;
18813 }
18814 ptr->counter[indx] = ctr;
18815 }
18816 }
18817 break;
18818
18819 case BOTTLEAMOUNT:
18820 {
18821 if(bottletype* ptr = checkBottleData(ri->bottletyperef, "Amount[]"))
18822 {
18823 int32_t indx = ri->d[rINDEX]/10000;
18824 int32_t amnt = vbound(value/10000, 0, 65535);
18825 if(unsigned(indx) > 2)
18826 {
18827 Z_scripterrlog("Invalid index %d supplied to bottledata->Amount[].\n", indx);
18828 break;
18829 }
18830 ptr->amount[indx] = amnt;
18831 }
18832 }
18833 break;
18834
18835 case BOTTLEPERCENT:
18836 {
18837 if(bottletype* ptr = checkBottleData(ri->bottletyperef, "IsPercent[]"))
18838 {
18839 int32_t indx = ri->d[rINDEX]/10000;
18840 if(unsigned(indx) > 2)
18841 {
18842 Z_scripterrlog("Invalid index %d supplied to bottledata->IsPercent[].\n", indx);
18843 break;
18844 }
18845 SETFLAG(ptr->flags, 1<<indx, value);
18846 }
18847 }
18848 break;
18849
18850 case BOTTLEFLAGS:
18851 {
18852 if(bottletype* ptr = checkBottleData(ri->bottletyperef, "Flags[]"))
18853 {
18854 int32_t indx = ri->d[rINDEX]/10000;
18855 if(unsigned(indx) > 3)
18856 {
18857 Z_scripterrlog("Invalid index %d supplied to bottledata->Flags[].\n", indx);
18858 break;
18859 }
18860 int32_t flag = 0;
18861 switch(indx)
18862 {
18863 case 0: flag = BTFLAG_AUTOONDEATH; break;
18864 case 1: flag = BTFLAG_ALLOWIFFULL; break;
18865 case 2: flag = BTFLAG_CURESWJINX; break;
18866 case 3: flag = BTFLAG_CUREITJINX; break;
18867 }
18868 SETFLAG(ptr->flags, flag, value);
18869 }
18870 }
18871 break;
18872
18873 case BOTTLENEXT:
18874 {
18875 if(bottletype* ptr = checkBottleData(ri->bottletyperef, "NextType"))
18876 {
18877 ptr->next_type = vbound(value/10000, 0, 64);
18878 }
18879 }
18880 break;
18881 ///----------------------------------------------------------------------------------------------------//
18882 //BottleShops
18883 case BSHOPFILL:
18884 {
18885 if(bottleshoptype* ptr = checkBottleShopData(ri->bottleshopref, "Fill[]"))
18886 {
18887 int32_t indx = ri->d[rINDEX]/10000;
18888 if(unsigned(indx) > 2)
18889 {
18890 Z_scripterrlog("Invalid index %d supplied to bottleshopdata->Fill[].\n", indx);
18891 break;
18892 }
18893 ptr->fill[indx] = vbound(value/10000, 0, 64);
18894 }
18895 }
18896 break;
18897
18898 case BSHOPCOMBO:
18899 {
18900 if(bottleshoptype* ptr = checkBottleShopData(ri->bottleshopref, "Combo[]"))
18901 {
18902 int32_t indx = ri->d[rINDEX]/10000;
18903 if(unsigned(indx) > 2)
18904 {
18905 Z_scripterrlog("Invalid index %d supplied to bottleshopdata->Combo[].\n", indx);
18906 break;
18907 }
18908 ptr->comb[indx] = vbound(value/10000, 0, MAXCOMBOS-1);
18909 }
18910 }
18911 break;
18912
18913 case BSHOPCSET:
18914 {
18915 if(bottleshoptype* ptr = checkBottleShopData(ri->bottleshopref, "CSet[]"))
18916 {
18917 int32_t indx = ri->d[rINDEX]/10000;
18918 if(unsigned(indx) > 2)
18919 {
18920 Z_scripterrlog("Invalid index %d supplied to bottleshopdata->CSet[].\n", indx);
18921 break;
18922 }
18923 ptr->cset[indx] = vbound(value/10000, 0, 11);
18924 }
18925 }
18926 break;
18927
18928 case BSHOPPRICE:
18929 {
18930 if(bottleshoptype* ptr = checkBottleShopData(ri->bottleshopref, "Price[]"))
18931 {
18932 int32_t indx = ri->d[rINDEX]/10000;
18933 if(unsigned(indx) > 2)
18934 {
18935 Z_scripterrlog("Invalid index %d supplied to bottleshopdata->Price[].\n", indx);
18936 break;
18937 }
18938 ptr->price[indx] = vbound(value/10000, 0, 65535);
18939 }
18940 }
18941 break;
18942
18943 case BSHOPSTR:
18944 {
18945 if(bottleshoptype* ptr = checkBottleShopData(ri->bottleshopref, "InfoString[]"))
18946 {
18947 int32_t indx = ri->d[rINDEX]/10000;
18948 if(unsigned(indx) > 2)
18949 {
18950 Z_scripterrlog("Invalid index %d supplied to bottleshopdata->InfoString[].\n", indx);
18951 break;
18952 }
18953 ptr->str[indx] = vbound(value/10000, 0, 65535);
18954 }
18955 }
18956 break;
18957 ///----------------------------------------------------------------------------------------------------//
18958 //DMap Information
18959
18960 #define SET_DMAP_VAR(member, str) \
18961 { \
18962 int32_t ID = ri->d[rINDEX] / 10000; \
18963 if(BC::checkDMapID(ID, str) == SH::_NoError) \
18964 DMaps[ID].member = value / 10000; \
18965 }
18966
18967 case DMAPFLAGSD:
18968 SET_DMAP_VAR(flags, "Game->DMapFlags") break;
18969
18970 case DMAPLEVELD:
18971 SET_DMAP_VAR(level, "Game->DMapLevel") break;
18972
18973 case DMAPCOMPASSD:
18974 SET_DMAP_VAR(compass, "Game->DMapCompass") break;
18975
18976 case DMAPCONTINUED:
18977 SET_DMAP_VAR(cont, "Game->DMapContinue") break;
18978
18979 case DMAPLEVELPAL:
18980 {
18981 377 int32_t ID = ri->d[rINDEX] / 10000;
18982 377 int32_t pal = value/10000;
18983 377 pal = vbound(pal, 0, 0x1FF);
18984
18985
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 377 times.
377 if(BC::checkDMapID(ID, "Game->DMapPalette") == SH::_NoError)
18986 377 DMaps[ID].color = pal;
18987
18988
2/2
✓ Branch 0 taken 367 times.
✓ Branch 1 taken 10 times.
377 if(ID == currdmap)
18989 {
18990 10 loadlvlpal(DMaps[ID].color);
18991 10 currcset = DMaps[ID].color;
18992 10 }
18993 377 break;
18994 }
18995
18996 case DMAPMIDID:
18997 {
18998 int32_t ID = ri->d[rINDEX] / 10000;
18999
19000 if(BC::checkDMapID(ID, "Game->DMapMIDI") == SH::_NoError)
19001 {
19002 // Based on play_DmapMusic
19003 switch(value / 10000)
19004 {
19005 case -6:
19006 DMaps[ID].midi = 2;
19007 break; // Dungeon
19008
19009 case -3:
19010 DMaps[ID].midi = 3;
19011 break; // Level 9
19012
19013 case -2:
19014 DMaps[ID].midi = 1;
19015 break; // Overworld
19016
19017 case 0:
19018 DMaps[ID].midi = 0;
19019 break; // None
19020
19021 default:
19022 DMaps[ID].midi = value / 10000 + 3;
19023 }
19024 }
19025
19026 break;
19027 }
19028
19029 ///----------------------------------------------------------------------------------------------------//
19030 //Screen->ComboX
19031 case COMBODD:
19032 {
19033 120341 int32_t pos = (ri->d[rINDEX])/10000;
19034 120341 int32_t val = (value/10000);
19035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120341 times.
120341 if ( ((unsigned) pos) > 175 )
19036 {
19037 Z_scripterrlog("Invalid [pos] %d used to write to Screen->ComboD[]\n", pos);
19038 }
19039
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120341 times.
120341 else if ( ((unsigned) val) >= MAXCOMBOS )
19040 {
19041 Z_scripterrlog("Invalid combo ID %d used to write to Screen->ComboD[]\n", val);
19042 }
19043 else
19044 {
19045 120341 screen_combo_modify_preroutine(tmpscr,pos);
19046 120341 tmpscr->data[pos]=(val);
19047 120341 screen_combo_modify_postroutine(tmpscr,pos);
19048 }
19049 }
19050 120341 break;
19051
19052 case COMBOCD:
19053 {
19054 6481 int32_t pos = (ri->d[rINDEX])/10000;
19055 6481 int32_t val = (value/10000); //cset
19056
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6481 times.
6481 if ( ((unsigned) pos) > 175 )
19057 {
19058 Z_scripterrlog("Invalid [pos] %d used to write to Screen->ComboC[]\n", pos);
19059 }
19060
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6481 times.
6481 else if ( ((unsigned) val) >= 15 )
19061 {
19062 Z_scripterrlog("Invalid CSet ID %d used to write to Screen->ComboC[]\n", val);
19063 }
19064 else
19065 {
19066 6481 screen_combo_modify_preroutine(tmpscr,pos);
19067 6481 tmpscr->cset[pos]=(val)&15;
19068 6481 screen_combo_modify_postroutine(tmpscr,pos);
19069 }
19070 }
19071 6481 break;
19072
19073 case COMBOFD:
19074 {
19075 int32_t pos = (ri->d[rINDEX])/10000;
19076 int32_t val = (value/10000); //flag
19077 if ( ((unsigned) pos) > 175 )
19078 {
19079 Z_scripterrlog("Invalid [pos] %d used to write to Screen->ComboF[]\n", pos);
19080 }
19081 else if ( ((unsigned) val) >= 256 )
19082 {
19083 Z_scripterrlog("Invalid Flag ID %d used to write to Screen->ComboF[]\n", val);
19084 }
19085
19086 else
19087 tmpscr->sflag[pos]=(val);
19088 }
19089 break;
19090
19091 case COMBOTD:
19092 {
19093 3560 int32_t pos = (ri->d[rINDEX])/10000;
19094 3560 int32_t val = (value/10000); //type
19095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3560 times.
3560 if ( ((unsigned) pos) > 175 )
19096 {
19097 Z_scripterrlog("Invalid [pos] %d used to write to Screen->ComboT[]\n", pos);
19098 }
19099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3560 times.
3560 else if ( ((unsigned) val) >= 256 )
19100 {
19101 Z_scripterrlog("Invalid Flag ID %d used to write to Screen->ComboT[]\n", val);
19102 }
19103 else
19104 {
19105 3560 auto cid = tmpscr->data[pos];
19106 3560 screen_combo_modify_pre(cid);
19107 3560 combobuf[cid].type=val;
19108 3560 screen_combo_modify_post(cid);
19109 }
19110 }
19111 3560 break;
19112
19113 case COMBOID:
19114 {
19115 int32_t pos = (ri->d[rINDEX])/10000;
19116 int32_t val = (value/10000); //iflag
19117 if ( ((unsigned) pos) > 175 )
19118 {
19119 Z_scripterrlog("Invalid [pos] %d used to write to Screen->ComboI[]\n", pos);
19120 }
19121 else if ( ((unsigned) val) >= 256 )
19122 {
19123 Z_scripterrlog("Invalid Flag ID %d used to write to Screen->ComboI[]\n", val);
19124 }
19125
19126 else
19127 combobuf[tmpscr->data[pos]].flag=val;
19128 }
19129 break;
19130
19131 case COMBOSD:
19132 {
19133 81346 int32_t pos = (ri->d[rINDEX])/10000;
19134 81346 int32_t val = (value/10000); //iflag
19135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81346 times.
81346 if ( ((unsigned) pos) > 175 )
19136 {
19137 Z_scripterrlog("Invalid [pos] %d used to write to Screen->ComboS[]\n", pos);
19138 }
19139
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81346 times.
81346 else if ( ((unsigned) val) >= 16 )//solidity 1, 2, 4, 8 max 15
19140 {
19141 Z_scripterrlog("Invalid Flag ID %d used to write to Screen->ComboS[]\n", val);
19142 }
19143 else
19144 {
19145 81346 combobuf[tmpscr->data[pos]].walk &= ~0x0F;
19146 81346 combobuf[tmpscr->data[pos]].walk |= (val)&0x0F;
19147 }
19148 }
19149 81346 break;
19150
19151 case COMBOED:
19152 {
19153 int32_t pos = (ri->d[rINDEX])/10000;
19154 int32_t val = (value/10000); //iflag
19155 if ( ((unsigned) pos) > 175 )
19156 {
19157 Z_scripterrlog("Invalid [pos] %d used to write to Screen->ComboE[]\n", pos);
19158 }
19159 else if ( ((unsigned) val) >= 16 )//solidity 1, 2, 4, 8 max 15
19160 {
19161 Z_scripterrlog("Invalid Flag ID %d used to write to Screen->ComboE[]\n", val);
19162 }
19163 else
19164 {
19165 combobuf[tmpscr->data[pos]].walk &= ~0xF0;
19166 combobuf[tmpscr->data[pos]].walk |= ((val)&0x0F)<<4;
19167 }
19168 }
19169 break;
19170
19171 ///----------------------------------------------------------------------------------------------------//
19172 //Game->SetComboX
19173 case COMBODDM:
19174 {
19175 5356632 int32_t pos = (ri->d[rINDEX])/10000;
19176 5356632 int32_t sc = (ri->d[rEXP1]/10000);
19177 5356632 int32_t m = (ri->d[rINDEX2]/10000)-1;
19178
2/2
✓ Branch 0 taken 5340616 times.
✓ Branch 1 taken 16016 times.
5356632 int32_t scr = zc_max(m*MAPSCRS+sc,0);
19179 5356632 int32_t layr = whichlayer(scr);
19180
19181 //if(!(pos >= 0 && pos < 176 && scr >= 0 && sc < MAPSCRS && m < map_count)) break;
19182
19183
2/4
✓ Branch 0 taken 5356632 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5356632 times.
5356632 if(pos < 0 || pos >= 176)
19184 {
19185 Z_scripterrlog("Invalid combo position (%d) passed to SetComboData", pos);
19186 break;
19187 }
19188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5356632 times.
5356632 if(scr < 0)
19189 {
19190 Z_scripterrlog("Invalid Screen ID (%d) passed to SetComboData", scr);
19191 break;
19192 }
19193
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5356632 times.
5356632 if(sc >= MAPSCRS)
19194 {
19195 Z_scripterrlog("Invalid Screen ID (%d) passed to SetComboData", sc);
19196 break;
19197 }
19198
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5356632 times.
5356632 if(unsigned(m) >= map_count)
19199 {
19200 Z_scripterrlog("Invalid Map ID (%d) passed to SetComboData", m);
19201 break;
19202 }
19203 5356632 int32_t combo = vbound(value/10000,0,MAXCOMBOS);
19204
2/2
✓ Branch 0 taken 5356419 times.
✓ Branch 1 taken 213 times.
5356632 if(scr==(currmap*MAPSCRS+currscr))
19205 {
19206 213 screen_combo_modify_preroutine(tmpscr,pos);
19207
19208 213 }
19209
19210 5356632 TheMaps[scr].data[pos]=combo;
19211
19212
2/2
✓ Branch 0 taken 5356419 times.
✓ Branch 1 taken 213 times.
5356632 if(scr==(currmap*MAPSCRS+currscr))
19213 {
19214 213 tmpscr->data[pos] = combo;
19215 213 screen_combo_modify_postroutine(tmpscr,pos);
19216 //Start the script for the new combo
19217 213 int index = get_combopos_ref(pos, 0);
19218 213 FFCore.reset_script_engine_data(ScriptType::Combo, index);
19219 //Not ure if combodata arrays clean themselves up, or leak. -Z
19220 //Not sure if this could result in stack corruption.
19221 213 }
19222
19223
2/2
✓ Branch 0 taken 5350083 times.
✓ Branch 1 taken 6549 times.
5356632 if(layr>-1)
19224 {
19225 6549 tmpscr2[layr].data[pos]=combo;
19226 6549 int index = get_combopos_ref(pos, layr + 1);
19227 6549 FFCore.reset_script_engine_data(ScriptType::Combo, index);
19228 6549 }
19229 }
19230 5356632 break;
19231
19232 case COMBOCDM:
19233 {
19234 5344380 int32_t pos = (ri->d[rINDEX])/10000;
19235 5344380 int32_t sc = (ri->d[rEXP1]/10000);
19236 5344380 int32_t m = (ri->d[rINDEX2]/10000)-1;
19237
2/2
✓ Branch 0 taken 5328364 times.
✓ Branch 1 taken 16016 times.
5344380 int32_t scr = zc_max(m*MAPSCRS+sc,0);
19238
19239 //if(!(pos >= 0 && pos < 176 && scr >= 0 && sc < MAPSCRS && m < map_count)) break;
19240
19241
2/4
✓ Branch 0 taken 5344380 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5344380 times.
5344380 if(pos < 0 || pos >= 176)
19242 {
19243 Z_scripterrlog("Invalid combo position (%d) passed to SetComboCSet", pos);
19244 break;
19245 }
19246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5344380 times.
5344380 if(scr < 0)
19247 {
19248 Z_scripterrlog("Invalid Screen ID (%d) passed to SetComboCSet", scr);
19249 break;
19250 }
19251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5344380 times.
5344380 if(sc >= MAPSCRS)
19252 {
19253 Z_scripterrlog("Invalid Screen ID (%d) passed to SetComboCSet", sc);
19254 break;
19255 }
19256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5344380 times.
5344380 if(unsigned(m) >= map_count)
19257 {
19258 Z_scripterrlog("Invalid Map ID (%d) passed to SetComboCSet", m);
19259 break;
19260 }
19261
19262 5344380 TheMaps[scr].cset[pos]=(value/10000)&15;
19263
19264
2/2
✓ Branch 0 taken 5344340 times.
✓ Branch 1 taken 40 times.
5344380 if(scr==(currmap*MAPSCRS+currscr))
19265 40 tmpscr->cset[pos] = value/10000;
19266
19267 5344380 int32_t layr = whichlayer(scr);
19268
19269
2/2
✓ Branch 0 taken 5341338 times.
✓ Branch 1 taken 3042 times.
5344380 if(layr>-1)
19270 3042 tmpscr2[layr].cset[pos]=(value/10000)&15;
19271 }
19272 5344380 break;
19273
19274 case COMBOFDM:
19275 {
19276 32221 int32_t pos = (ri->d[rINDEX])/10000;
19277 32221 int32_t sc = (ri->d[rEXP1]/10000);
19278 32221 int32_t m = (ri->d[rINDEX2]/10000)-1;
19279
1/2
✓ Branch 0 taken 32221 times.
✗ Branch 1 not taken.
32221 int32_t scr = zc_max(m*MAPSCRS+sc,0);
19280
19281 //if(!(pos >= 0 && pos < 176 && scr >= 0 && sc < MAPSCRS && m < map_count)) break;
19282
19283
2/4
✓ Branch 0 taken 32221 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 32221 times.
32221 if(pos < 0 || pos >= 176)
19284 {
19285 Z_scripterrlog("Invalid combo position (%d) passed to SetComboFlag", pos);
19286 break;
19287 }
19288
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32221 times.
32221 if(scr < 0)
19289 {
19290 Z_scripterrlog("Invalid Screen ID (%d) passed to SetComboFlag", scr);
19291 break;
19292 }
19293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32221 times.
32221 if(sc >= MAPSCRS)
19294 {
19295 Z_scripterrlog("Invalid Screen ID (%d) passed to SetComboFlag", sc);
19296 break;
19297 }
19298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32221 times.
32221 if(unsigned(m) >= map_count)
19299 {
19300 Z_scripterrlog("Invalid Map ID (%d) passed to SetComboFlag", m);
19301 break;
19302 }
19303
19304 32221 TheMaps[scr].sflag[pos]=value/10000;
19305
19306
2/2
✓ Branch 0 taken 32153 times.
✓ Branch 1 taken 68 times.
32221 if(scr==(currmap*MAPSCRS+currscr))
19307 68 tmpscr->sflag[pos] = value/10000;
19308
19309 32221 int32_t layr = whichlayer(scr);
19310
19311
2/2
✓ Branch 0 taken 32210 times.
✓ Branch 1 taken 11 times.
32221 if(layr>-1)
19312 11 tmpscr2[layr].sflag[pos]=value/10000;
19313 }
19314 32221 break;
19315
19316 case COMBOTDM:
19317 {
19318 760 int32_t pos = (ri->d[rINDEX])/10000;
19319 760 int32_t sc = (ri->d[rEXP1]/10000);
19320 760 int32_t m = (ri->d[rINDEX2]/10000)-1;
19321
1/2
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
760 int32_t scr = zc_max(m*MAPSCRS+sc,0);
19322
19323 //if(!(pos >= 0 && pos < 176 && scr >= 0 && sc < MAPSCRS && m < map_count))
19324 // break;
19325
19326
2/4
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 760 times.
760 if(pos < 0 || pos >= 176)
19327 {
19328 Z_scripterrlog("Invalid combo position (%d) passed to SetComboType", pos);
19329 break;
19330 }
19331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(scr < 0)
19332 {
19333 Z_scripterrlog("Invalid Screen ID (%d) passed to SetComboType", scr);
19334 break;
19335 }
19336
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(sc >= MAPSCRS)
19337 {
19338 Z_scripterrlog("Invalid Screen ID (%d) passed to SetComboType", sc);
19339 break;
19340 }
19341
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
760 if(unsigned(m) >= map_count)
19342 {
19343 Z_scripterrlog("Invalid Map ID (%d) passed to SetComboType", m);
19344 break;
19345 }
19346
19347 760 int32_t cdata = TheMaps[scr].data[pos];
19348 760 screen_combo_modify_pre(cdata);
19349 760 combobuf[cdata].type=value/10000;
19350 760 screen_combo_modify_post(cdata);
19351 }
19352 760 break;
19353
19354 case COMBOIDM:
19355 {
19356 int32_t pos = (ri->d[rINDEX])/10000;
19357 int32_t sc = (ri->d[rEXP1]/10000);
19358 int32_t m = (ri->d[rINDEX2]/10000)-1;
19359 int32_t scr = zc_max(m*MAPSCRS+sc,0);
19360
19361 //if(!(pos >= 0 && pos < 176 && scr >= 0 && sc < MAPSCRS && m < map_count))
19362 // break;
19363
19364 if(pos < 0 || pos >= 176)
19365 {
19366 Z_scripterrlog("Invalid combo position (%d) passed to GetComboInherentFlag", pos);
19367 break;
19368 }
19369 if(scr < 0)
19370 {
19371 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboInherentFlag", scr);
19372 break;
19373 }
19374 if(sc >= MAPSCRS)
19375 {
19376 Z_scripterrlog("Invalid Screen ID (%d) passed to GetComboInherentFlag", sc);
19377 break;
19378 }
19379 if(unsigned(m) >= map_count)
19380 {
19381 Z_scripterrlog("Invalid Map ID (%d) passed to GetComboInherentFlag", m);
19382 break;
19383 }
19384
19385 combobuf[TheMaps[scr].data[pos]].flag=value/10000;
19386 }
19387 break;
19388
19389 case COMBOSDM:
19390 {
19391 //This is how it was in 2.50.1-2
19392 int32_t pos = (ri->d[rINDEX])/10000;
19393 int32_t scr = (ri->d[rINDEX2]/10000)*MAPSCRS+(ri->d[rEXP1]/10000);
19394 //This (below) us the precise code from 2.50.1 (?)
19395 //int32_t scr = zc_max((ri->d[rINDEX2]/10000)*MAPSCRS+(ri->d[rEXP1]/10000),0); //Not below 0.
19396
19397 //if(pos < 0 || pos >= 176 || scr < 0) break;
19398 if(pos < 0 || pos >= 176)
19399 {
19400 Z_scripterrlog("Invalid combo position (%d) passed to GetSolid", pos);
19401 break;
19402 }
19403 if(scr < 0)
19404 {
19405 Z_scripterrlog("Invalid MapScreen ID (%d) passed to GetSolid", scr);
19406 break;
19407 }
19408 combobuf[TheMaps[scr].data[pos]].walk &= ~0x0F;
19409 combobuf[TheMaps[scr].data[pos]].walk |= (value/10000)&15;
19410 }
19411 break;
19412
19413 ///----------------------------------------------------------------------------------------------------//
19414 //Screen Variables
19415
19416 #define SET_SCREENDATA_VAR_INT32(member, str) \
19417 { \
19418 tmpscr->member = vbound((value / 10000),-214747,214747); \
19419 } \
19420
19421 #define SET_SCREENDATA_VAR_INT16(member, str) \
19422 { \
19423 tmpscr->member = vbound((value / 10000),0,32767); \
19424 } \
19425
19426 #define SET_SCREENDATA_VAR_BYTE(member, str) \
19427 { \
19428 tmpscr->member = vbound((value / 10000),0,255); \
19429 } \
19430
19431 #define SET_SCREENDATA_VAR_INDEX32(member, str, indexbound) \
19432 { \
19433 int32_t indx = ri->d[rINDEX] / 10000; \
19434 tmpscr->member[indx] = vbound((value / 10000),-214747,214747); \
19435 } \
19436
19437 #define SET_SCREENDATA_VAR_INDEX16(member, str, indexbound) \
19438 { \
19439 int32_t indx = ri->d[rINDEX] / 10000; \
19440 tmpscr->member[indx] = vbound((value / 10000),-32767,32767); \
19441 } \
19442
19443 #define SET_SCREENDATA_BYTE_INDEX(member, str, indexbound) \
19444 { \
19445 int32_t indx = ri->d[rINDEX] / 10000; \
19446 tmpscr->member[indx] = vbound((value / 10000),0,255); \
19447 }
19448 #define SET_SCREENDATA_LAYER_INDEX(member, str, indexbound) \
19449 { \
19450 int32_t indx = ri->d[rINDEX] / 10000; \
19451 if ( FFCore.quest_format[vFFScript] < 11 ) ++indx; \
19452 if(indx < 1 || indx > indexbound ) \
19453 { \
19454 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
19455 } \
19456 else tmpscr->member[indx-1] = vbound((value / 10000),0,255); \
19457 }
19458 ///max screen id is higher! vbound properly... -Z
19459 #define SET_SCREENDATA_LAYERSCREEN_INDEX(member, str, indexbound) \
19460 { \
19461 int32_t indx = ri->d[rINDEX] / 10000; \
19462 int32_t scrn_id = value/10000; \
19463 if ( FFCore.quest_format[vFFScript] < 11 ) ++indx; \
19464 if(indx < 1 || indx > indexbound ) \
19465 { \
19466 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
19467 } \
19468 else if ( scrn_id > MAPSCRS ) \
19469 { \
19470 Z_scripterrlog("Script attempted to use a mapdata->LayerScreen[%d].\n",scrn_id); \
19471 Z_scripterrlog("Valid Screen values are (0) through (%d).\n",MAPSCRS); \
19472 } \
19473 else tmpscr->member[indx-1] = vbound((scrn_id),0,MAPSCRS); \
19474 }
19475
19476 #define SET_SCREENDATA_FLAG(member, str) \
19477 { \
19478 int32_t flag = (value/10000); \
19479 if ( flag != 0 ) \
19480 { \
19481 tmpscr->member|=flag; \
19482 } \
19483 else tmpscr->.member|= ~flag; \
19484 } \
19485
19486 #define SET_SCREENDATA_BOOL_INDEX(member, str, indexbound) \
19487 { \
19488 int32_t indx = ri->d[rINDEX] / 10000; \
19489 if(indx < 0 || indx > indexbound ) \
19490 { \
19491 Z_scripterrlog("Invalid Index passed to Screen->%s[]: %d\n", (indx), str); \
19492 break; \
19493 } \
19494 tmpscr->member[indx] =( (value/10000) ? 1 : 0 ); \
19495 }
19496
19497 #define SET_FFC_BOOL_INDEX(member, str, indexbound) \
19498 { \
19499 int32_t indx = ri->d[rINDEX] / 10000; \
19500 if(indx < 0 || indx > indexbound ) \
19501 { \
19502 Z_scripterrlog("Invalid Index passed to Screen->%s[]: %d\n", (indx), str); \
19503 break; \
19504 } \
19505 tmpscr->ffcs[indx].member =( (value/10000) ? 1 : 0 ); \
19506 }
19507
19508
19509 case SCREENDATAVALID: SET_SCREENDATA_VAR_BYTE(valid, "Valid"); break; //b
19510 case SCREENDATAGUY: SET_SCREENDATA_VAR_BYTE(guy, "Guy"); break; //b
19511 case SCREENDATASTRING: SET_SCREENDATA_VAR_INT32(str, "String"); break; //w
19512 case SCREENDATAROOM: SET_SCREENDATA_VAR_BYTE(room, "RoomType"); break; //b
19513 case SCREENDATAITEM:
19514 {
19515 auto v = vbound((value / 10000),-1,255);
19516 if(v > -1)
19517 tmpscr->item = v;
19518 tmpscr->hasitem = v > -1;
19519 break;
19520 }
19521 case SCREENDATAHASITEM: SET_SCREENDATA_VAR_BYTE(hasitem, "HasItem"); break; //b
19522 case SCREENDATATILEWARPTYPE: SET_SCREENDATA_BYTE_INDEX(tilewarptype, "TileWarpType", 3); break; //b, 4 of these
19523 //case SCREENDATATILEWARPOVFLAGS: SET_SCREENDATA_VAR_BYTE(tilewarpoverlayflags, "TileWarpOverlayFlags"); break; //b, tilewarpoverlayflags
19524 case SCREENDATADOORCOMBOSET: SET_SCREENDATA_VAR_INT32(door_combo_set, "DoorComboSet"); break; //w
19525 case SCREENDATAWARPRETX: SET_SCREENDATA_BYTE_INDEX(warpreturnx, "WarpReturnX", 3); break; //b, 4 of these
19526 case SCREENDATAWARPRETY: SET_SCREENDATA_BYTE_INDEX(warpreturny, "WarpReturnY", 3); break; //b, 4 of these
19527 case SCREENDATAWARPRETURNC: SET_SCREENDATA_VAR_INT32(warpreturnc, "WarpReturnC"); break; //w
19528 case SCREENDATASTAIRX: SET_SCREENDATA_VAR_BYTE(stairx, "StairsX"); break; //b
19529 case SCREENDATASTAIRY: SET_SCREENDATA_VAR_BYTE(stairy, "StairsY"); break; //b
19530 case SCREENDATAITEMX: SET_SCREENDATA_VAR_BYTE(itemx, "ItemX"); break; //itemx
19531 case SCREENDATAITEMY: SET_SCREENDATA_VAR_BYTE(itemy, "ItemY"); break; //itemy
19532 case SCREENDATACOLOUR: SET_SCREENDATA_VAR_INT32(color, "CSet"); break; //w
19533 case SCREENDATAENEMYFLAGS: SET_SCREENDATA_VAR_BYTE(enemyflags, "EnemyFlags"); break; //b
19534 case SCREENDATADOOR: SET_SCREENDATA_BYTE_INDEX(door, "Door", 3); break; //b, 4 of these
19535 case SCREENDATATILEWARPDMAP: SET_SCREENDATA_VAR_INDEX32(tilewarpdmap, "TileWarpDMap", 3); break; //w, 4 of these
19536 case SCREENDATATILEWARPSCREEN: SET_SCREENDATA_BYTE_INDEX(tilewarpscr, "TileWarpScreen", 3); break; //b, 4 of these
19537 case SCREENDATAEXITDIR: SET_SCREENDATA_VAR_BYTE(exitdir, "ExitDir"); break; //b
19538 case SCREENDATAENEMY:
19539 {
19540 int32_t indx = ri->d[rINDEX] / 10000;
19541 int32_t enemyid = value/10000;
19542 if ( ((unsigned)enemyid) > MAXGUYS )
19543 {
19544 Z_scripterrlog("Invaid enemy ID (%d) passed to Screen->%s.", enemyid,"Enemy[]"); \
19545 break;
19546 }
19547 if(unsigned(indx) > 9)
19548 {
19549 Z_scripterrlog("Invalid index (%d) used for Screen->Enemy[]", indx);
19550 break;
19551 }
19552 tmpscr->enemy[indx] = enemyid;
19553 break;
19554 }
19555 //case SCREENDATAENEMY: SET_SCREENDATA_VAR_INDEX32(enemy, "Enemy", 9); break; //w, 10 of these
19556 case SCREENDATAPATTERN: SET_SCREENDATA_VAR_BYTE(pattern, "Pattern"); break; //b
19557 case SCREENDATASIDEWARPTYPE: SET_SCREENDATA_BYTE_INDEX(sidewarptype, "SideWarpType", 3); break; //b, 4 of these
19558 //case SCREENDATASIDEWARPOVFLAGS: SET_SCREENDATA_VAR_BYTE(sidewarpoverlayflags, "SideWarpOverlayFlags"); break; //b
19559 case SCREENDATAWARPARRIVALX: SET_SCREENDATA_VAR_BYTE(warparrivalx, "WarpArrivalX"); break; //b
19560 case SCREENDATAWARPARRIVALY: SET_SCREENDATA_VAR_BYTE(warparrivaly, "WarpArrivalY"); break; //b
19561 case SCREENDATAPATH: SET_SCREENDATA_BYTE_INDEX(path, "MazePath", 3); break; //b, 4 of these
19562 case SCREENDATASIDEWARPSC: SET_SCREENDATA_BYTE_INDEX(sidewarpscr, "SideWarpScreen", 3); break; //b, 4 of these
19563 case SCREENDATASIDEWARPDMAP: SET_SCREENDATA_VAR_INDEX32(sidewarpdmap, "SideWarpDMap", 3); break; //w, 4 of these
19564 case SCREENDATASIDEWARPINDEX: SET_SCREENDATA_VAR_BYTE(sidewarpindex, "SideWarpIndex"); break; //b
19565 case SCREENDATAUNDERCOMBO: SET_SCREENDATA_VAR_INT32(undercombo, "Undercombo"); break; //w
19566 case SCREENDATAUNDERCSET: SET_SCREENDATA_VAR_BYTE(undercset, "UnderCSet"); break; //b
19567 case SCREENDATACATCHALL: SET_SCREENDATA_VAR_INT32(catchall, "Catchall"); break; //W
19568
19569 case SCREENDATACSENSITIVE: SET_SCREENDATA_VAR_BYTE(csensitive, "CSensitive"); break; //B
19570 case SCREENDATANORESET: SET_SCREENDATA_VAR_INT32(noreset, "NoReset"); break; //W
19571 case SCREENDATANOCARRY: SET_SCREENDATA_VAR_INT32(nocarry, "NoCarry"); break; //W
19572 case SCREENDATALAYERMAP: SET_SCREENDATA_LAYER_INDEX(layermap, "LayerMap", 5); break; //B, 6 OF THESE
19573 case SCREENDATALAYERSCREEN: SET_SCREENDATA_LAYERSCREEN_INDEX(layerscreen, "LayerScreen", 5); break; //B, 6 OF THESE
19574 case SCREENDATALAYEROPACITY: SET_SCREENDATA_LAYER_INDEX(layeropacity, "LayerOpacity", 5); break; //B, 6 OF THESE
19575 case SCREENDATALAYERINVIS:
19576 {
19577 int32_t indx = ri->d[rINDEX] / 10000;
19578 if(indx < 0 || indx > 6 )
19579 {
19580 Z_scripterrlog("Invalid Index passed to Screen->LayerInvisible[]: %d\n", indx);
19581 }
19582 else
19583 {
19584 if(value)
19585 tmpscr->hidelayers |= (1<<indx);
19586 else
19587 tmpscr->hidelayers &= ~(1<<indx);
19588 }
19589 break;
19590 }
19591 case SCREENDATASCRIPTDRAWS:
19592 {
19593 int32_t indx = ri->d[rINDEX] / 10000;
19594 if(indx < 0 || indx > 7 )
19595 {
19596 Z_scripterrlog("Invalid Index passed to Screen->HideScriptLayer[]: %d\n", indx);
19597 }
19598 else
19599 {
19600 if(value)
19601 tmpscr->hidescriptlayers &= ~(1<<indx);
19602 else
19603 tmpscr->hidescriptlayers |= (1<<indx);
19604 }
19605 break;
19606 }
19607
19608 case SCREENDATATILEWARPOVFLAGS:
19609 {
19610 int32_t indx = ri->d[rINDEX] / 10000;
19611 if ( ((unsigned)indx) > 3 )
19612 {
19613 Z_scripterrlog("Invalid index passed to TileWarpOverlayFlags[%d].\n. Valid indices are [0] through [3].\n", indx);
19614 }
19615 else
19616 {
19617 if ( value ) tmpscr->tilewarpoverlayflags |= (1<<indx);
19618 else tmpscr->tilewarpoverlayflags &= ~(1<<indx);
19619 }
19620 break;
19621 }
19622
19623 case SCREENDATASIDEWARPOVFLAGS:
19624 {
19625 int32_t indx = ri->d[rINDEX] / 10000;
19626 if ( ((unsigned)indx) > 3 )
19627 {
19628 Z_scripterrlog("Invalid index passed to SideWarpOverlayFlags[%d].\n. Valid indices are [0] through [3].\n", indx);
19629 }
19630 else
19631 {
19632 if ( value ) tmpscr->sidewarpoverlayflags |= (1<<indx);
19633 else tmpscr->sidewarpoverlayflags &= ~(1<<indx);
19634 }
19635 break;
19636 }
19637
19638 case SCREENDATATIMEDWARPTICS: SET_SCREENDATA_VAR_INT32(timedwarptics, "TimedWarpTimer"); break; //W
19639 case SCREENDATANEXTMAP: SET_SCREENDATA_VAR_BYTE(nextmap, "NextMap"); break; //B
19640 case SCREENDATANEXTSCREEN: SET_SCREENDATA_VAR_BYTE(nextscr, "NextScreen"); break; //B
19641 128 case SCREENDATASECRETCOMBO: SET_SCREENDATA_VAR_INDEX32(secretcombo, "SecretCombo", 127); break; //W, 128 OF THESE
19642 128 case SCREENDATASECRETCSET: SET_SCREENDATA_BYTE_INDEX(secretcset, "SecretCSet", 127); break; //B, 128 OF THESE
19643 128 case SCREENDATASECRETFLAG: SET_SCREENDATA_BYTE_INDEX(secretflag, "SecretFlags", 127); break; //B, 128 OF THESE
19644 case SCREENDATAVIEWX: break;//SET_SCREENDATA_VAR_INT32(viewX, "ViewX"); break; //W
19645 case SCREENDATAVIEWY: break;//SET_SCREENDATA_VAR_INT32(viewY, "ViewY"); break; //W
19646 case SCREENDATASCREENWIDTH: break;//SET_SCREENDATA_VAR_BYTE(scrWidth, "Width"); break; //B
19647 case SCREENDATASCREENHEIGHT: break;//SET_SCREENDATA_VAR_BYTE(scrHeight, "Height"); break; //B
19648 case SCREENDATAENTRYX:
19649 {
19650 5 int32_t newx = vbound((value/10000),0,255);
19651 5 tmpscr->entry_x = newx;
19652
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if ( get_qr(qr_WRITE_ENTRYPOINTS_AFFECTS_HEROCLASS) )
19653 {
19654 Hero.respawn_x = (zfix)(newx);
19655 }
19656 5 break;
19657 }
19658 case SCREENDATAENTRYY:
19659 {
19660
19661 5 int32_t newy = vbound((value/10000),0,175);
19662 5 tmpscr->entry_y = newy;
19663
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if ( get_qr(qr_WRITE_ENTRYPOINTS_AFFECTS_HEROCLASS) )
19664 {
19665 Hero.respawn_y = (zfix)(newy);
19666 }
19667 5 break; //B
19668 }
19669
19670 case SCREENDATANUMFF:
19671 {
19672 break;
19673 }
19674
19675 case SCREENDATAFFINITIALISED:
19676 {
19677 int32_t indx = ri->d[rINDEX] / 10000;
19678 if (indx < 0 || indx > MAXFFCS-1)
19679 {
19680 Z_scripterrlog("Invalid Index passed to Screen->%s[]: %d\n", (indx), "FFCRunning");
19681 break;
19682 }
19683 get_script_engine_data(ScriptType::FFC, indx).initialized = (value/10000) ? true : false;
19684 }
19685 break;
19686
19687 case SCREENDATASCRIPTENTRY: SET_SCREENDATA_VAR_INT32(script_entry, "ScriptEntry"); break; //W
19688 case SCREENDATASCRIPTOCCUPANCY: SET_SCREENDATA_VAR_INT32(script_occupancy, "ScriptOccupancy"); break;//W
19689 case SCREENDATASCRIPTEXIT: SET_SCREENDATA_VAR_INT32(script_exit, "ExitScript"); break; //W
19690 case SCREENDATAOCEANSFX:
19691 {
19692 int32_t v = vbound(value/10000, 0, 255);
19693 if(tmpscr->oceansfx != v)
19694 {
19695 stop_sfx(tmpscr->oceansfx);
19696 tmpscr->oceansfx = v;
19697 cont_sfx(tmpscr->oceansfx);
19698 }
19699 break;
19700 }
19701 case SCREENDATABOSSSFX: SET_SCREENDATA_VAR_BYTE(bosssfx, "BossSFX"); break; //B
19702 case SCREENDATASECRETSFX: SET_SCREENDATA_VAR_BYTE(secretsfx, "SecretSFX"); break; //B
19703 case SCREENDATAHOLDUPSFX: SET_SCREENDATA_VAR_BYTE(holdupsfx, "ItemSFX"); break; //B
19704 case SCREENDATASCREENMIDI:
19705 {
19706 tmpscr->screen_midi = vbound((value / 10000)-(MIDIOFFSET_MAPSCR-MIDIOFFSET_ZSCRIPT),-1,32767);
19707 break;
19708 }
19709 case SCREENDATALENSLAYER: SET_SCREENDATA_VAR_BYTE(lens_layer, "LensLayer"); break; //B, OLD QUESTS ONLY?
19710
19711 case SCREENSIDEWARPID:
19712 {
19713 int32_t indx = ri->d[rINDEX] / 10000; //dir
19714
19715 int32_t new_warp_return = vbound((value / 10000),-1,3); //none, A, B, C, D
19716 if(new_warp_return == -1)
19717 {
19718 tmpscr->flags2 &= ~(1<<indx); //Unset the "Enabled" flag for this dir
19719 tmpscr->sidewarpindex &= ~(3<<(2*indx)); //Clear the dir as well.
19720 }
19721 else
19722 {
19723 tmpscr->flags2 |= 1<<indx; //Set the "Enabled" flag for this dir
19724 tmpscr->sidewarpindex &= ~(3<<(2*indx)); //Clear the dir bits
19725 tmpscr->sidewarpindex |= (new_warp_return<<(2*indx)); //Set the new dir
19726 }
19727
19728 break;
19729 }
19730
19731 case SCREENDATATWARPRETSQR:
19732 {
19733 int32_t indx = ri->d[rINDEX] / 10000;
19734 if ( ((unsigned)indx) > 3)
19735 {
19736 Z_scripterrlog("Invalid Array Index passed to Screen->TileWarpReturnSquare[]: %d\n", indx);
19737 }
19738 else
19739 {
19740 int32_t wrindex = vbound(value/10000, 0, 3);
19741 tmpscr->warpreturnc = (tmpscr->warpreturnc&~(3<<(indx*2))) | (wrindex<<(indx*2));
19742 }
19743 break;
19744 }
19745
19746 //
19747 case SCREENDATASWARPRETSQR:
19748 {
19749
19750 int32_t indx = ri->d[rINDEX] / 10000;
19751 if ( ((unsigned)indx) > 3)
19752 {
19753 Z_scripterrlog("Invalid Array Index passed to Screen->SideWarpReturnSquare[]: %d\n", indx);
19754 }
19755 else
19756 {
19757 int32_t wrindex = vbound(value/10000, 0, 3);
19758 tmpscr->warpreturnc = (tmpscr->warpreturnc&~(3<<(8+(indx*2)))) | (wrindex<<(8+(indx*2)));
19759 }
19760 break;
19761 }
19762
19763
19764 case SCREENDATAFLAGS:
19765 {
19766 int32_t flagid = (ri->d[rINDEX])/10000;
19767 //bool valtrue = ( value ? 10000 : 0);
19768 switch(flagid)
19769 {
19770 case 0: tmpscr->flags = (value / 10000); break;
19771 case 1: tmpscr->flags2 = (value / 10000); break;
19772 case 2: tmpscr->flags3 = (value / 10000); break;
19773 case 3: tmpscr->flags4 = (value / 10000); break;
19774 case 4: tmpscr->flags5 = (value / 10000); break;
19775 case 5: tmpscr->flags6 = (value / 10000); break;
19776 case 6: tmpscr->flags7 = (value / 10000); break;
19777 case 7: tmpscr->flags8 = (value / 10000); break;
19778 case 8: tmpscr->flags9 = (value / 10000); break;
19779 case 9: tmpscr->flags10 = (value / 10000); break;
19780 default:
19781 {
19782 Z_scripterrlog("Invalid index passed to mapdata->flags[]: %d\n", flagid);
19783 break;
19784
19785 }
19786 }
19787 break;
19788 //GET_SCREENDATA_BYTE_INDEX //B, 11 OF THESE, flags, flags2-flags10
19789 }
19790
19791
19792 //These use the same method as SetScreenD
19793 case SCREENWIDTH:
19794 // FFScript::set_screenWidth(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
19795 break;
19796
19797 case SCREENHEIGHT:
19798 // FFScript::set_screenHeight(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
19799 break;
19800
19801 case SCREENVIEWX:
19802 // FFScript::set_screenViewX(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
19803 break;
19804
19805 case SCREENVIEWY:
19806 // FFScript::set_screenViewY(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
19807 break;
19808
19809 case SCREENGUY:
19810 FFScript::set_screenGuy(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
19811 break;
19812
19813 case SCREENSTRING:
19814 {
19815 FFScript::set_screenString(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
19816 //should this be either
19817 //set_screenString(&TheMaps[((ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)])-1), value/10000);
19818 //or
19819 //set_screenString(&TheMaps[((ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)])-+1), value/10000);
19820 Z_message("Map ref is: %d\n",((ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)));
19821 }
19822 break;
19823
19824 case SCREENROOM:
19825 FFScript::set_screenRoomtype(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
19826 break;
19827
19828 case SCREENENTX:
19829 FFScript::set_screenEntryX(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
19830 break;
19831
19832 case SCREENENTY:
19833 FFScript::set_screenEntryY(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
19834 break;
19835
19836 case SCREENITEM:
19837 FFScript::set_screenitem(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
19838 break;
19839
19840 case SCREENUNDCMB:
19841 FFScript::set_screenundercombo(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
19842 break;
19843
19844 case SCREENUNDCST:
19845 FFScript::set_screenundercset(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
19846 break;
19847
19848 case SCREENCATCH:
19849 FFScript::set_screenatchall(&TheMaps[(ri->d[rINDEX2] / 10000) * MAPSCRS + (ri->d[rINDEX]/10000)], value/10000);
19850 break;
19851
19852 //These use the method of SetScreenEnemy
19853
19854
19855 //SetScreenLayerOpacity(int32_t map, int32_t scr, int32_t layer, int32_t v)
19856 case SETSCREENLAYOP:
19857 {
19858 int32_t map = (ri->d[rINDEX2] / 10000) - 1; //Should this be +1? -Z
19859 int32_t scrn = ri->d[rEXP1] / 10000;
19860 int32_t index = ri->d[rINDEX] / 10000;
19861 int32_t nn = ri->d[rEXP2]/10000;
19862
19863 if(BC::checkMapID(map, "Game->SetScreenLayerOpacity(...map...)") != SH::_NoError ||
19864 BC::checkBounds(scrn, 0, 0x87, "Game->SetScreenLayerOpacity(...screen...)") != SH::_NoError ||
19865 BC::checkBounds(index, 0, 9, "Game->SetScreenLayerOpacity(...index...)") != SH::_NoError)
19866 return;
19867
19868 FFScript::set_screenlayeropacity(&TheMaps[map * MAPSCRS + scrn], index, nn);
19869 }
19870 break;
19871
19872 case SETSCREENSECCMB:
19873 {
19874 int32_t map = (ri->d[rINDEX2] / 10000) - 1; //Should this be +1? -Z
19875 int32_t scrn = ri->d[rEXP1] / 10000;
19876 int32_t index = ri->d[rINDEX] / 10000;
19877 int32_t nn = ri->d[rEXP2]/10000;
19878
19879 if(BC::checkMapID(map, "Game->SetScreenSecretCombo(...map...)") != SH::_NoError ||
19880 BC::checkBounds(scrn, 0, 0x87, "Game->SetScreenSecretCombo(...screen...)") != SH::_NoError ||
19881 BC::checkBounds(index, 0, 9, "Game->SetScreenSecretCombo(...index...)") != SH::_NoError)
19882 return;
19883
19884 FFScript::set_screensecretcombo(&TheMaps[map * MAPSCRS + scrn], index, nn);
19885 }
19886 break;
19887
19888 case SETSCREENSECCST:
19889 {
19890 int32_t map = (ri->d[rINDEX2] / 10000) - 1; //Should this be +1? -Z
19891 int32_t scrn = ri->d[rEXP1] / 10000;
19892 int32_t index = ri->d[rINDEX] / 10000;
19893 int32_t nn = ri->d[rEXP2]/10000;
19894
19895 if(BC::checkMapID(map, "Game->SetScreenSecretCSet(...map...)") != SH::_NoError ||
19896 BC::checkBounds(scrn, 0, 0x87, "Game->SetScreenSecretCSet(...screen...)") != SH::_NoError ||
19897 BC::checkBounds(index, 0, 9, "Game->SetScreenSecretCSet(...index...)") != SH::_NoError)
19898 return;
19899
19900 FFScript::set_screensecretcset(&TheMaps[map * MAPSCRS + scrn], index, nn);
19901 }
19902 break;
19903
19904 case SETSCREENSECFLG:
19905 {
19906 int32_t map = (ri->d[rINDEX2] / 10000) - 1; //Should this be +1? -Z
19907 int32_t scrn = ri->d[rEXP1] / 10000;
19908 int32_t index = ri->d[rINDEX] / 10000;
19909 int32_t nn = ri->d[rEXP2]/10000;
19910
19911 if(BC::checkMapID(map, "Game->SetScreenSecretFlag(...map...)") != SH::_NoError ||
19912 BC::checkBounds(scrn, 0, 0x87, "Game->SetScreenSecretFlag(...screen...)") != SH::_NoError ||
19913 BC::checkBounds(index, 0, 9, "Game->SetScreenSecretFlag(...index...)") != SH::_NoError)
19914 return;
19915
19916 FFScript::set_screensecretflag(&TheMaps[map * MAPSCRS + scrn], index, nn);
19917 }
19918 break;
19919
19920 case SETSCREENLAYMAP:
19921 {
19922 int32_t map = (ri->d[rINDEX2] / 10000) - 1; //Should this be +1? -Z
19923 int32_t scrn = ri->d[rEXP1] / 10000;
19924 int32_t index = ri->d[rINDEX] / 10000;
19925 int32_t nn = ri->d[rEXP2]/10000;
19926
19927 if(BC::checkMapID(map, "Game->SetScreenLayerMap(...map...)") != SH::_NoError ||
19928 BC::checkBounds(scrn, 0, 0x87, "Game->SetScreenLayerMap(...screen...)") != SH::_NoError ||
19929 BC::checkBounds(index, 0, 9, "Game->SetScreenLayerMap(...index...)") != SH::_NoError)
19930 return;
19931
19932 FFScript::set_screenlayermap(&TheMaps[map * MAPSCRS + scrn], index, nn);
19933 }
19934 break;
19935
19936 case SETSCREENLAYSCR:
19937 {
19938 int32_t map = (ri->d[rINDEX2] / 10000) - 1; //Should this be +1? -Z
19939 int32_t scrn = ri->d[rEXP1] / 10000;
19940 int32_t index = ri->d[rINDEX] / 10000;
19941 int32_t nn = ri->d[rEXP2]/10000;
19942
19943 if(BC::checkMapID(map, "Game->SetScreenLayerScreen(...map...)") != SH::_NoError ||
19944 BC::checkBounds(scrn, 0, 0x87, "Game->SetScreenLayerScreen(...screen...)") != SH::_NoError ||
19945 BC::checkBounds(index, 0, 9, "Game->SetScreenLayerScreen(...index...)") != SH::_NoError)
19946 return;
19947
19948 FFScript::set_screenlayerscreen(&TheMaps[map * MAPSCRS + scrn], index, nn);
19949 }
19950 break;
19951
19952 case SETSCREENPATH:
19953 {
19954 int32_t map = (ri->d[rINDEX2] / 10000) - 1; //Should this be +1? -Z
19955 int32_t scrn = ri->d[rEXP1] / 10000;
19956 int32_t index = ri->d[rINDEX] / 10000;
19957 int32_t nn = ri->d[rEXP2]/10000;
19958
19959 if(BC::checkMapID(map, "Game->SetScreenPath(...map...)") != SH::_NoError ||
19960 BC::checkBounds(scrn, 0, 0x87, "Game->SetScreenPath(...screen...)") != SH::_NoError ||
19961 BC::checkBounds(index, 0, 9, "Game->SetScreenPath(...index...)") != SH::_NoError)
19962 return;
19963
19964 FFScript::set_screenpath(&TheMaps[map * MAPSCRS + scrn], index, nn);
19965 }
19966 break;
19967
19968 case SETSCREENWARPRX:
19969 {
19970 int32_t map = (ri->d[rINDEX2] / 10000) - 1; //Should this be +1? -Z
19971 int32_t scrn = ri->d[rEXP1] / 10000;
19972 int32_t index = ri->d[rINDEX] / 10000;
19973 int32_t nn = ri->d[rEXP2]/10000;
19974
19975 if(BC::checkMapID(map, "Game->SetScreenWarpReturnX(...map...)") != SH::_NoError ||
19976 BC::checkBounds(scrn, 0, 0x87, "Game->SetScreenWarpReturnX(...screen...)") != SH::_NoError ||
19977 BC::checkBounds(index, 0, 9, "Game->SetScreenWarpReturnX(...index...)") != SH::_NoError)
19978 return;
19979
19980 FFScript::set_screenwarpReturnX(&TheMaps[map * MAPSCRS + scrn], index, nn);
19981 }
19982 break;
19983
19984 case SETSCREENWARPRY:
19985 {
19986 int32_t map = (ri->d[rINDEX2] / 10000) - 1; //Should this be +1? -Z
19987 int32_t scrn = ri->d[rEXP1] / 10000;
19988 int32_t index = ri->d[rINDEX] / 10000;
19989 int32_t nn = ri->d[rEXP2]/10000;
19990
19991 if(BC::checkMapID(map, "Game->SetScreenWarpReturnY(...map...)") != SH::_NoError ||
19992 BC::checkBounds(scrn, 0, 0x87, "Game->SetScreenWarpReturnY(...screen...)") != SH::_NoError ||
19993 BC::checkBounds(index, 0, 9, "Game->SetScreenWarpReturnY(...index...)") != SH::_NoError)
19994 return;
19995
19996 FFScript::set_screenwarpReturnY(&TheMaps[map * MAPSCRS + scrn], index, nn);
19997 }
19998 break;
19999
20000 case SDD:
20001 {
20002 {
20003
2/2
✓ Branch 0 taken 14236 times.
✓ Branch 1 taken 41 times.
14277 int32_t di2 = ((get_currdmap())<<7) + get_currscr()-(DMaps[get_currdmap()].type==dmOVERW ? 0 : DMaps[get_currdmap()].xoff);
20004 14277 FFScript::set_screen_d(di2, ri->d[rINDEX]/10000, value);
20005 14277 break;
20006 }
20007 }
20008
20009 case GDD:
20010 al_trace("GDD");
20011 game->global_d[ri->d[rINDEX]/10000]=value;
20012 break;
20013
20014 case SDDD:
20015 27297 FFScript::set_screen_d((ri->d[rINDEX])/10000 + ((get_currdmap())<<7), ri->d[rINDEX2]/10000, value);
20016 27297 break;
20017
20018 case SDDDD:
20019 531 FFScript::set_screen_d(ri->d[rINDEX2]/10000 + ((ri->d[rINDEX]/10000)<<7), ri->d[rEXP1]/10000, value);
20020 531 break;
20021
20022 case SCREENINITD:
20023 tmpscr->screeninitd[ri->d[rINDEX]/10000] = value;
20024 break;
20025
20026 case SCREENSCRIPT:
20027 {
20028 FFScript::deallocateAllArrays(ScriptType::Screen, 0);
20029
20030 if ( get_qr(qr_CLEARINITDONSCRIPTCHANGE))
20031 {
20032 for(int32_t q=0; q<8; q++)
20033 tmpscr->screeninitd[q] = 0;
20034 }
20035 FFCore.ref(ScriptType::Screen, 0).Clear();
20036 tmpscr->script=vbound(value/10000, 0, NUMSCRIPTSCREEN-1);
20037 break;
20038 }
20039
20040 case MAPDATAINITD:
20041 tmpscr->screeninitd[ri->d[rINDEX]/10000]=value;
20042 break;
20043
20044 case SCRDOORD:
20045 4 tmpscr->door[ri->d[rINDEX]/10000]=value/10000;
20046 4 putdoor(scrollbuf,0,ri->d[rINDEX]/10000,value/10000,true,true);
20047 4 break;
20048
20049 case LIT:
20050 900 naturaldark = !value;
20051 900 lighting(false, false);
20052 900 break;
20053
20054 case WAVY:
20055 7214 wavy=value/10000;
20056 7214 break;
20057
20058 case QUAKE:
20059 3579 quakeclk=value/10000;
20060 3579 break;
20061
20062 case ROOMTYPE:
20063 tmpscr->room=value/10000; break; //this probably doesn't work too well...
20064
20065 case ROOMDATA:
20066 11 tmpscr->catchall=value/10000;
20067 11 break;
20068
20069 case PUSHBLOCKLAYER:
20070 mblock2.blockLayer=vbound(value/10000, 0, 6);
20071 break;
20072
20073 case PUSHBLOCKCOMBO:
20074 mblock2.bcombo=value/10000;
20075 break;
20076
20077 case PUSHBLOCKCSET:
20078 mblock2.cs=value/10000;
20079 mblock2.oldcset=value/10000;
20080 break;
20081
20082 case UNDERCOMBO:
20083 tmpscr->undercombo=value/10000;
20084 break;
20085
20086 case UNDERCSET:
20087 tmpscr->undercset=value/10000;
20088 break;
20089
20090
20091 case DEBUGGDR:
20092 {
20093 int32_t a = vbound(ri->d[rINDEX]/10000,0,15);
20094 game->global_d[a] = value / 10000;;
20095 break;
20096 }
20097
20098 case DEBUGSP:
20099 SH::write_stack(ri->sp,vbound((value / 10000),0,MAX_SCRIPT_REGISTERS-1));
20100 break;
20101
20102 case DEBUGREFFFC:
20103 ri->ffcref = vbound((value / 10000),1,MAXFFCS-1);
20104 break;
20105
20106 case DEBUGREFITEM:
20107 ri->itemref = vbound((value / 10000),0,255);
20108 break;
20109
20110 case DEBUGREFITEMDATA:
20111 ri->idata = vbound((value / 10000),0,255);
20112 break;
20113
20114 case DEBUGREFLWEAPON:
20115 ri->lwpn = vbound((value / 10000),0,255);
20116 break;
20117
20118 case DEBUGREFEWEAPON:
20119 ri->ewpn = vbound((value / 10000),0,255);
20120 break;
20121
20122 case DEBUGREFNPC:
20123 ri->guyref = vbound((value / 10000),0,255);
20124 break;
20125
20126
20127 //Game Over Screen
20128 case SETGAMEOVERELEMENT:
20129 {
20130 int32_t colour = value/10000;
20131 int32_t index = ri->d[rINDEX]/10000;
20132 index = vbound(index,0,SAVESC_LAST-1);
20133 // zprint("GameOverScreen Index,Value: %d,%ld/n",index,colour);
20134 SetSaveScreenSetting(index,colour);
20135 break;
20136 }
20137
20138 case SETGAMEOVERSTRING:
20139 {
20140 int32_t arrayptr = value/10000;
20141 int32_t index = ri->d[rINDEX]/10000;
20142 index = vbound(index,0,SAVESC_END-1);
20143 string filename_str;
20144 ArrayH::getString(arrayptr, filename_str, 73);
20145 ChangeSubscreenText(index,filename_str.c_str());
20146 break;
20147 }
20148
20149 ///----------------------------------------------------------------------------------------------------//
20150 //New Datatype Variables
20151
20152 ///----------------------------------------------------------------------------------------------------//
20153 //spritedata sp-> Variables
20154 case SPRITEDATATILE: SET_SPRITEDATA_VAR_INT(tile, "Tile"); break;
20155 case SPRITEDATAMISC: SET_SPRITEDATA_VAR_BYTE(misc, "Misc"); break;
20156 case SPRITEDATACSETS:
20157 {
20158 if(unsigned(ri->spritesref) > (MAXWPNS-1) )
20159 {
20160 Z_scripterrlog("Invalid Sprite ID passed to spritedata->CSet: %d\n", (ri->spritesref*10000));
20161 }
20162 else
20163 {
20164 wpnsbuf[ri->spritesref].csets &= 0xF0;
20165 wpnsbuf[ri->spritesref].csets |= vbound((value / 10000),0,15);
20166 }
20167 break;
20168 }
20169 case SPRITEDATAFLCSET:
20170 {
20171 if(unsigned(ri->spritesref) > (MAXWPNS-1) )
20172 {
20173 Z_scripterrlog("Invalid Sprite ID passed to spritedata->FlashCSet: %d\n", (ri->spritesref*10000));
20174 }
20175 else
20176 {
20177 wpnsbuf[ri->spritesref].csets &= 0x0F;
20178 wpnsbuf[ri->spritesref].csets |= vbound((value / 10000),0,15)<<4;
20179 }
20180 break;
20181 }
20182 case SPRITEDATAFRAMES: SET_SPRITEDATA_VAR_BYTE(frames, "Frames"); break;
20183 case SPRITEDATASPEED: SET_SPRITEDATA_VAR_BYTE(speed, "Speed"); break;
20184 case SPRITEDATATYPE: SET_SPRITEDATA_VAR_BYTE(type, "Type"); break;
20185 case SPRITEDATAFLAGS:
20186 {
20187 if(unsigned(ri->spritesref) > (MAXWPNS-1) )
20188 {
20189 Z_scripterrlog("Invalid Sprite ID passed to spritedata->Flags[]: %d\n", (ri->spritesref*10000));
20190 break;
20191 }
20192 int32_t index = ri->d[rINDEX]/10000;
20193 if(unsigned(index) >= 5)
20194 {
20195 Z_scripterrlog("Invalid index passed to spritedata->Flags[]: %d\n", index);
20196 break;
20197 }
20198 SETFLAG(wpnsbuf[ri->spritesref].misc, 1<<index, value);
20199 break;
20200 }
20201
20202 ///----------------------------------------------------------------------------------------------------//
20203 //mapdata m-> Variables
20204 //mapdata m-> Variables
20205
20206 #define SET_MAPDATA_VAR_INT32(member, str) \
20207 { \
20208 if (mapscr *m = GetMapscr(ri->mapsref)) \
20209 { \
20210 m->member = vbound((value / 10000),-214747,214747); \
20211 } \
20212 else \
20213 { \
20214 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
20215 } \
20216 break; \
20217 } \
20218
20219 #define SET_MAPDATA_VAR_INT16(member, str) \
20220 { \
20221 if (mapscr *m = GetMapscr(ri->mapsref)) \
20222 { \
20223 m->member = vbound((value / 10000),0,32767); \
20224 } \
20225 else \
20226 { \
20227 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
20228 } \
20229 break; \
20230 } \
20231
20232 #define SET_MAPDATA_VAR_BYTE(member, str) \
20233 { \
20234 if (mapscr *m = GetMapscr(ri->mapsref)) \
20235 { \
20236 m->member = vbound((value / 10000),0,255); \
20237 } \
20238 else \
20239 { \
20240 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
20241 } \
20242 break; \
20243 } \
20244
20245 #define SET_MAPDATA_VAR_INDEX32(member, str, indexbound) \
20246 { \
20247 int32_t indx = ri->d[rINDEX] / 10000; \
20248 if(indx < 0 || indx > indexbound ) \
20249 { \
20250 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
20251 } \
20252 else if (mapscr *m = GetMapscr(ri->mapsref)) \
20253 { \
20254 m->member[indx] = vbound((value / 10000),-214747,214747); \
20255 } \
20256 else \
20257 { \
20258 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
20259 } \
20260 break; \
20261 } \
20262
20263 #define SET_MAPDATA_VAR_INDEX16(member, str, indexbound) \
20264 { \
20265 int32_t indx = ri->d[rINDEX] / 10000; \
20266 if(indx < 0 || indx > indexbound ) \
20267 { \
20268 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
20269 } \
20270 else if (mapscr *m = GetMapscr(ri->mapsref)) \
20271 { \
20272 m->member[indx] = vbound((value / 10000),-32767,32767); \
20273 } \
20274 else \
20275 { \
20276 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
20277 } \
20278 break; \
20279 } \
20280
20281 #define SET_MAPDATA_BYTE_INDEX(member, str, indexbound) \
20282 { \
20283 int32_t indx = ri->d[rINDEX] / 10000; \
20284 if(indx < 0 || indx > indexbound ) \
20285 { \
20286 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
20287 } \
20288 else if (mapscr *m = GetMapscr(ri->mapsref)) \
20289 { \
20290 m->member[indx] = vbound((value / 10000),0,255); \
20291 } \
20292 else \
20293 { \
20294 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
20295 } \
20296 break; \
20297 }\
20298
20299 #define SET_MAPDATA_LAYER_INDEX(member, str, indexbound) \
20300 { \
20301 int32_t indx = ri->d[rINDEX] / 10000; \
20302 if ( FFCore.quest_format[vFFScript] < 11 ) ++indx; \
20303 if(indx < 1 || indx > indexbound ) \
20304 { \
20305 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
20306 } \
20307 else if (mapscr *m = GetMapscr(ri->mapsref)) \
20308 { \
20309 m->member[indx-1] = vbound((value / 10000),0,255); \
20310 } \
20311 else \
20312 { \
20313 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
20314 } \
20315 break; \
20316 } \
20317
20318 #define SET_MAPDATA_LAYERSCREEN_INDEX(member, str, indexbound) \
20319 { \
20320 int32_t indx = ri->d[rINDEX] / 10000; \
20321 if ( FFCore.quest_format[vFFScript] < 11 ) ++indx; \
20322 int32_t scrn_id = value/10000; \
20323 if(indx < 1 || indx > indexbound ) \
20324 { \
20325 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
20326 } \
20327 else if ( scrn_id > MAPSCRS ) \
20328 { \
20329 Z_scripterrlog("Script attempted to use a mapdata->LayerScreen[%d].\n",scrn_id); \
20330 Z_scripterrlog("Valid Screen values are (0) through (%d).\n",MAPSCRS); \
20331 } \
20332 else if (mapscr *m = GetMapscr(ri->mapsref)) \
20333 { \
20334 m->member[indx-1] = vbound((scrn_id),0,MAPSCRS); \
20335 } \
20336 else \
20337 { \
20338 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
20339 } \
20340 break; \
20341 }\
20342
20343 #define SET_MAPDATA_BOOL_INDEX(member, str, indexbound) \
20344 { \
20345 int32_t indx = ri->d[rINDEX] / 10000; \
20346 if(indx < 0 || indx > indexbound ) \
20347 { \
20348 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
20349 } \
20350 else if (mapscr *m = GetMapscr(ri->mapsref)) \
20351 { \
20352 m->member[indx] =( (value/10000) ? 1 : 0 ); \
20353 } \
20354 else \
20355 { \
20356 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
20357 } \
20358 break; \
20359 } \
20360
20361 #define SET_FFC_MAPDATA_BOOL_INDEX(member, str, indexbound) \
20362 { \
20363 int32_t indx = ri->d[rINDEX] / 10000; \
20364 if(indx < 0 || indx > indexbound ) \
20365 { \
20366 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", str, indx); \
20367 } \
20368 else if (mapscr *m = GetMapscr(ri->mapsref)) \
20369 { \
20370 m->ffcs[indx].member =( (value/10000) ? 1 : 0 ); \
20371 } \
20372 else \
20373 { \
20374 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
20375 } \
20376 break; \
20377 } \
20378
20379 #define SET_MAPDATA_FLAG(member, str) \
20380 { \
20381 int32_t flag = (value/10000); \
20382 if (mapscr *m = GetMapscr(ri->mapsref)) \
20383 { \
20384 if ( flag != 0 ) \
20385 { \
20386 m->member|=flag; \
20387 } \
20388 else m->.member|= ~flag; \
20389 } \
20390 else \
20391 { \
20392 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n",str); \
20393 } \
20394 break; \
20395 } \
20396
20397 #define SET_MAPDATA_FFCPOS_INDEX32(member, str, indexbound) \
20398 { \
20399 int32_t indx = (ri->d[rINDEX] / 10000)-1; \
20400 if(indx < 0 || indx > indexbound ) \
20401 { \
20402 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", (indx+1), str); \
20403 } \
20404 else if (mapscr *m = GetMapscr(ri->mapsref)) \
20405 { \
20406 m->ffcs[indx].member = zslongToFix(value); \
20407 } \
20408 else \
20409 { \
20410 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","str"); \
20411 } \
20412 break; \
20413 } \
20414
20415 #define SET_MAPDATA_FFC_INDEX32(member, str, indexbound) \
20416 { \
20417 int32_t indx = (ri->d[rINDEX] / 10000)-1; \
20418 if(indx < 0 || indx > indexbound ) \
20419 { \
20420 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", (indx+1), str); \
20421 } \
20422 else if (mapscr *m = GetMapscr(ri->mapsref)) \
20423 { \
20424 m->ffcs[indx].member = value/10000; \
20425 } \
20426 else \
20427 { \
20428 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","str"); \
20429 } \
20430 break; \
20431 } \
20432
20433 #define SET_MAPDATA_FFC_INDEX_VBOUND(member, str, indexbound, min, max) \
20434 { \
20435 int32_t v = value/10000; \
20436 int32_t indx = (ri->d[rINDEX] / 10000)-1; \
20437 if(indx < 0 || indx > indexbound ) \
20438 { \
20439 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", (indx+1), str); \
20440 } \
20441 else if(v < min || v > max ) \
20442 { \
20443 Z_scripterrlog("Invalid value assigned to mapdata->%s[]: %d\n", (indx+1), str); \
20444 } \
20445 else if (mapscr *m = GetMapscr(ri->mapsref)) \
20446 { \
20447 m->ffcs[indx].member = v; \
20448 } \
20449 else \
20450 { \
20451 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","str"); \
20452 } \
20453 break; \
20454 } \
20455
20456 case MAPDATAVALID: SET_MAPDATA_VAR_BYTE(valid, "Valid"); break; //b
20457 case MAPDATAGUY: SET_MAPDATA_VAR_BYTE(guy, "Guy"); break; //b
20458 case MAPDATASTRING: SET_MAPDATA_VAR_INT32(str, "String"); break; //w
20459 case MAPDATAROOM: SET_MAPDATA_VAR_BYTE(room, "RoomType"); break; //b
20460 case MAPDATAITEM:
20461 {
20462 if (mapscr *m = GetMapscr(ri->mapsref))
20463 {
20464 auto v = vbound((value / 10000),-1,255);
20465 if(v > -1)
20466 m->item = v;
20467 m->hasitem = v > -1;
20468 }
20469 else
20470 {
20471 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","Item");
20472 }
20473 break;
20474 }
20475 case MAPDATAHASITEM: SET_MAPDATA_VAR_BYTE(hasitem, "HasItem"); break; //b
20476 case MAPDATATILEWARPTYPE: SET_MAPDATA_BYTE_INDEX(tilewarptype, "TileWarpType", 3); break; //b, 4 of these
20477 //case MAPDATATILEWARPOVFLAGS: SET_MAPDATA_VAR_BYTE(tilewarpoverlayflags, "TileWarpOverlayFlags"); break; //b, tilewarpoverlayflags
20478 case MAPDATADOORCOMBOSET: SET_MAPDATA_VAR_INT32(door_combo_set, "DoorComboSet"); break; //w
20479 case MAPDATAWARPRETX: SET_MAPDATA_BYTE_INDEX(warpreturnx, "WarpReturnX", 3); break; //b, 4 of these
20480 case MAPDATAWARPRETY: SET_MAPDATA_BYTE_INDEX(warpreturny, "WarpReturnY", 3); break; //b, 4 of these
20481 case MAPDATAWARPRETURNC: SET_MAPDATA_VAR_INT32(warpreturnc, "WarpReturnC"); break; //w
20482 case MAPDATASTAIRX: SET_MAPDATA_VAR_BYTE(stairx, "StairsX"); break; //b
20483 case MAPDATASTAIRY: SET_MAPDATA_VAR_BYTE(stairy, "StairsY"); break; //b
20484 case MAPDATAITEMX: SET_MAPDATA_VAR_BYTE(itemx, "ItemX"); break; //itemx
20485 case MAPDATAITEMY: SET_MAPDATA_VAR_BYTE(itemy, "ItemY"); break; //itemy
20486 case MAPDATACOLOUR: SET_MAPDATA_VAR_INT32(color, "CSet"); break; //w
20487 case MAPDATAENEMYFLAGS: SET_MAPDATA_VAR_BYTE(enemyflags, "EnemyFlags"); break; //b
20488 case MAPDATADOOR: SET_MAPDATA_BYTE_INDEX(door, "Door", 3); break; //b, 4 of these
20489 case MAPDATATILEWARPDMAP: SET_MAPDATA_VAR_INDEX32(tilewarpdmap, "TileWarpDMap", 3); break; //w, 4 of these
20490 case MAPDATATILEWARPSCREEN: SET_MAPDATA_BYTE_INDEX(tilewarpscr, "TileWarpScreen", 3); break; //b, 4 of these
20491 case MAPDATAEXITDIR: SET_MAPDATA_VAR_BYTE(exitdir, "ExitDir"); break; //b
20492 case MAPDATAENEMY:
20493 {
20494 int32_t indx = (ri->d[rINDEX] / 10000);
20495 int32_t enemyid = value/10000;
20496 if( ((unsigned)indx) > 9 )
20497 {
20498 Z_scripterrlog("Invalid Index passed to mapdata->%s: %d\n", "Enemy[]", (indx));
20499 }
20500 else if ( ((unsigned)enemyid) > MAXGUYS )
20501 {
20502 Z_scripterrlog("Invaid enemy ID (%d) passed to Mapdata->%s.", enemyid,"Enemy[]");
20503 }
20504 else if (mapscr *m = GetMapscr(ri->mapsref))
20505 {
20506 m->enemy[indx] = enemyid;
20507 }
20508 else
20509 {
20510 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","Enemy[]");
20511 }
20512 break;
20513 }
20514 //case MAPDATAENEMY: SET_MAPDATA_VAR_INDEX32(enemy, "Enemy", 9); break; //w, 10 of these
20515 case MAPDATAPATTERN: SET_MAPDATA_VAR_BYTE(pattern, "Pattern"); break; //b
20516 case MAPDATASIDEWARPTYPE: SET_MAPDATA_BYTE_INDEX(sidewarptype, "SideWarpType", 3); break; //b, 4 of these
20517 //case MAPDATASIDEWARPOVFLAGS: SET_MAPDATA_VAR_BYTE(sidewarpoverlayflags, "SideWarpOverlayFlags"); break; //b
20518 case MAPDATAWARPARRIVALX: SET_MAPDATA_VAR_BYTE(warparrivalx, "WarpArrivalX"); break; //b
20519 case MAPDATAWARPARRIVALY: SET_MAPDATA_VAR_BYTE(warparrivaly, "WarpArrivalY"); break; //b
20520 case MAPDATAPATH: SET_MAPDATA_BYTE_INDEX(path, "MazePath", 3); break; //b, 4 of these
20521 case MAPDATASIDEWARPSC: SET_MAPDATA_BYTE_INDEX(sidewarpscr, "SideWarpScreen", 3); break; //b, 4 of these
20522 case MAPDATAINITDARRAY:
20523 {
20524
20525 if (mapscr *m = GetMapscr(ri->mapsref))
20526 {
20527 m->screeninitd[ri->d[rINDEX]/10000] = value;
20528 }
20529 else
20530 {
20531 Z_scripterrlog("Script attempted to use a mapdata->InitD[%d] on a pointer that is uninitialised\n",ri->d[rINDEX]/10000);
20532 }
20533 break;
20534 }
20535
20536
20537 case MAPDATALAYERINVIS:
20538 {
20539 int32_t indx = ri->d[rINDEX] / 10000;
20540 if(indx < 0 || indx > 6 )
20541 {
20542 Z_scripterrlog("Invalid Index passed to mapdata->LayerInvisible[]: %d\n", indx);
20543 }
20544 else
20545 {
20546
20547 if (mapscr *m = GetMapscr(ri->mapsref))
20548 {
20549 if(value)
20550 {
20551 tmpscr->hidelayers |= (1<<indx);
20552 }
20553 else
20554 {
20555 tmpscr->hidelayers &= ~(1<<indx);
20556 }
20557 }
20558 else
20559 {
20560 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","LayerInvisible");
20561 }
20562 }
20563 break;
20564 }
20565 case MAPDATASCRIPTDRAWS:
20566 {
20567 int32_t indx = ri->d[rINDEX] / 10000;
20568 if(indx < 0 || indx > 7 )
20569 {
20570 Z_scripterrlog("Invalid Index passed to mapdata->DisableScriptDraw[]: %d\n", indx);
20571 }
20572 else
20573 {
20574 if (mapscr *m = GetMapscr(ri->mapsref))
20575 {
20576 if(value)
20577 {
20578 tmpscr->hidescriptlayers &= ~(1<<indx);
20579 }
20580 else
20581 {
20582 tmpscr->hidescriptlayers |= (1<<indx);
20583 }
20584 }
20585 else
20586 {
20587 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","DisableScriptDraw");
20588 }
20589 }
20590 break;
20591 }
20592
20593 case MAPDATATILEWARPOVFLAGS:
20594 {
20595 int32_t indx = ri->d[rINDEX] / 10000;
20596 if ( ((unsigned)indx) > 3 )
20597 {
20598 Z_scripterrlog("Invalid index passed to TileWarpOverlayFlags[%d].\n. Valid indices are [0] through [3].\n", indx);
20599 }
20600 else if (mapscr *m = GetMapscr(ri->mapsref))
20601 {
20602 if ( value ) m->tilewarpoverlayflags |= (1<<indx);
20603 else m->tilewarpoverlayflags &= ~(1<<indx);
20604 }
20605 else
20606 {
20607 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","NumFFCs[]");
20608 }
20609 break;
20610 }
20611
20612 case MAPDATASIDEWARPOVFLAGS:
20613 {
20614 int32_t indx = ri->d[rINDEX] / 10000;
20615 if ( ((unsigned)indx) > 3 )
20616 {
20617 Z_scripterrlog("Invalid index passed to SideWarpOverlayFlags[%d].\n. Valid indices are [0] through [3].\n", indx);
20618 }
20619 else if (mapscr *m = GetMapscr(ri->mapsref))
20620 {
20621 if ( value ) m->sidewarpoverlayflags |= (1<<indx);
20622 else m->sidewarpoverlayflags &= ~(1<<indx);
20623 }
20624 else
20625 {
20626 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","NumFFCs[]");
20627 }
20628 break;
20629 }
20630
20631 case MAPDATASIDEWARPDMAP: SET_MAPDATA_VAR_INDEX32(sidewarpdmap, "SideWarpDMap", 3); break; //w, 4 of these
20632 case MAPDATASIDEWARPINDEX: SET_MAPDATA_VAR_BYTE(sidewarpindex, "SideWarpIndex"); break; //b
20633 case MAPDATAUNDERCOMBO: SET_MAPDATA_VAR_INT32(undercombo, "UnderCombo"); break; //w
20634 case MAPDATAUNDERCSET: SET_MAPDATA_VAR_BYTE(undercset, "UnderCSet"); break; //b
20635 case MAPDATACATCHALL: SET_MAPDATA_VAR_INT32(catchall, "Catchall"); break; //W
20636
20637 case MAPDATACSENSITIVE: SET_MAPDATA_VAR_BYTE(csensitive, "CSensitive"); break; //B
20638 case MAPDATANORESET: SET_MAPDATA_VAR_INT32(noreset, "NoReset"); break; //W
20639 case MAPDATANOCARRY: SET_MAPDATA_VAR_INT32(nocarry, "NoCarry"); break; //W
20640 //! Layer arrays should be a size of 7, and return the current screen / map / and OP_OPAQUE
20641 //! if you try to read 0, so that they correspond to actual layer IDs.
20642 //!
20643 case MAPDATALAYERMAP: SET_MAPDATA_LAYER_INDEX(layermap, "LayerMap", 6); break; //B, 6 OF THESE
20644 case MAPDATALAYERSCREEN: SET_MAPDATA_LAYERSCREEN_INDEX(layerscreen, "LayerScreen", 6); break; //B, 6 OF THESE
20645 case MAPDATALAYEROPACITY: SET_MAPDATA_LAYER_INDEX(layeropacity, "LayerOpacity", 6); break; //B, 6 OF THESE
20646 case MAPDATATIMEDWARPTICS: SET_MAPDATA_VAR_INT32(timedwarptics, "TimedWarpTimer"); break; //W
20647 case MAPDATANEXTMAP: SET_MAPDATA_VAR_BYTE(nextmap, "NextMap"); break; //B
20648 case MAPDATANEXTSCREEN: SET_MAPDATA_VAR_BYTE(nextscr, "NextScreen"); break; //B
20649 case MAPDATASECRETCOMBO: SET_MAPDATA_VAR_INDEX32(secretcombo, "SecretCombo", 127); break; //W, 128 OF THESE
20650 case MAPDATASECRETCSET: SET_MAPDATA_BYTE_INDEX(secretcset, "SecretCSet", 127); break; //B, 128 OF THESE
20651 case MAPDATASECRETFLAG: SET_MAPDATA_BYTE_INDEX(secretflag, "SecretFlags", 127); break; //B, 128 OF THESE
20652 case MAPDATAVIEWX: break;//SET_MAPDATA_VAR_INT32(viewX, "ViewX"); break; //W
20653 case MAPDATASCRIPT:
20654 {
20655 if (mapscr *m = GetMapscr(ri->mapsref))
20656 {
20657 if(ri->mapsref == MAPSCR_TEMP0) //This mapsref references tmpscr, so can reference a running script!
20658 {
20659 FFScript::deallocateAllArrays(ScriptType::Screen, 0);
20660
20661 if ( get_qr(qr_CLEARINITDONSCRIPTCHANGE))
20662 {
20663 for(int32_t q=0; q<8; q++)
20664 tmpscr->screeninitd[q] = 0;
20665 }
20666
20667 FFCore.ref(ScriptType::Screen, 0).Clear();
20668 }
20669 m->script=vbound(value/10000, 0, NUMSCRIPTSCREEN-1);
20670 }
20671 else
20672 {
20673 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","Script");
20674 }
20675 break;
20676
20677 }
20678 case MAPDATAVIEWY: break;//SET_MAPDATA_VAR_INT32(viewY, "ViewY"); break; //W
20679 case MAPDATASCREENWIDTH: break;//SET_MAPDATA_VAR_BYTE(scrWidth, "Width"); break; //B
20680 case MAPDATASCREENHEIGHT: break;//SET_MAPDATA_VAR_BYTE(scrHeight, "Height"); break; //B
20681 case MAPDATAENTRYX: SET_MAPDATA_VAR_BYTE(entry_x, "EntryX"); break; //B
20682 case MAPDATAENTRYY: SET_MAPDATA_VAR_BYTE(entry_y, "EntryY"); break; //B
20683 case MAPDATAFFDATA:
20684 {
20685 int32_t indx = (ri->d[rINDEX] / 10000)-1;
20686 if(indx < 0 || indx > MAXFFCS-1 )
20687 {
20688 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", (indx+1), "FFCData");
20689 }
20690 else if (mapscr *m = GetMapscr(ri->mapsref))
20691 {
20692 m->ffcs[indx].setData(value/10000);
20693 }
20694 else
20695 {
20696 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised", "FFCData");
20697 }
20698 break; //W, MAXFFCS OF THESE
20699 }
20700 case MAPDATAFFCSET: SET_MAPDATA_FFC_INDEX32(cset, "FFCCSet", MAXFFCS-1); break; //B, MAXFFCS
20701 case MAPDATAFFDELAY: SET_MAPDATA_FFC_INDEX32(delay, "FFCDelay", MAXFFCS-1); break; //W, MAXFFCS
20702 case MAPDATAFFX: SET_MAPDATA_FFCPOS_INDEX32(x, "FFCX", MAXFFCS-1); break; //INT32, MAXFFCS OF THESE
20703 case MAPDATAFFY: SET_MAPDATA_FFCPOS_INDEX32(y, "FFCY", MAXFFCS-1); break; //..
20704 case MAPDATAFFXDELTA: SET_MAPDATA_FFCPOS_INDEX32(vx, "FFCVx", MAXFFCS-1); break; //..
20705 case MAPDATAFFYDELTA: SET_MAPDATA_FFCPOS_INDEX32(vy, "FFCVy", MAXFFCS-1); break; //..
20706 case MAPDATAFFXDELTA2: SET_MAPDATA_FFCPOS_INDEX32(ax, "FFCAx", MAXFFCS-1); break; //..
20707 case MAPDATAFFYDELTA2: SET_MAPDATA_FFCPOS_INDEX32(ay, "FFCAy", MAXFFCS-1); break; //..
20708
20709 case MAPDATAFFFLAGS:
20710 {
20711 int32_t indx = (ri->d[rINDEX] / 10000)-1;
20712 if(indx < 0 || indx > MAXFFCS-1)
20713 {
20714 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", (indx+1), "FFCFlags");
20715 }
20716 else if (mapscr *m = GetMapscr(ri->mapsref))
20717 {
20718 m->ffcs[indx].flags = value/10000;
20719 m->ffcs[indx].updateSolid();
20720 }
20721 else
20722 {
20723 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","FFCFlags");
20724 }
20725 break;
20726 }
20727
20728 //Number of ffcs that are in use (have valid data
20729 case MAPDATANUMFF:
20730 {
20731 break;
20732 }
20733
20734 case MAPDATASIDEWARPID:
20735 {
20736
20737 int32_t indx = ri->d[rINDEX] / 10000; //dir
20738 if (mapscr *m = GetMapscr(ri->mapsref))
20739 {
20740 int32_t new_warp_return = vbound((value / 10000),-1,3); //none, A, B, C, D
20741 if(new_warp_return == -1)
20742 {
20743 m->flags2 &= ~(1<<indx); //Unset the "Enabled" flag for this dir
20744 m->sidewarpindex &= ~(3<<(2*indx)); //Clear the dir as well.
20745 }
20746 else
20747 {
20748 m->flags2 |= 1<<indx; //Set the "Enabled" flag for this dir
20749 m->sidewarpindex &= ~(3<<(2*indx)); //Clear the dir bits
20750 m->sidewarpindex |= (new_warp_return<<(2*indx)); //Set the new dir
20751 }
20752 }
20753 else
20754 {
20755 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","SideWarpID");
20756 }
20757 break;
20758 }
20759
20760 case MAPDATATWARPRETSQR:
20761 {
20762 int32_t indx = ri->d[rINDEX] / 10000;
20763 if ( ((unsigned)indx) > 3)
20764 {
20765 Z_scripterrlog("Invalid Array Index passed to mapdata->TileWarpReturnSquare[]: %d\n", indx);
20766 }
20767 else if (mapscr *m = GetMapscr(ri->mapsref))
20768 {
20769 int32_t wrindex = vbound(value/10000, 0, 3);
20770 m->warpreturnc = (m->warpreturnc&~(3<<(indx*2))) | (wrindex<<(indx*2));
20771 }
20772 else
20773 {
20774 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","str");
20775 }
20776 break;
20777 }
20778
20779 //
20780 case MAPDATASWARPRETSQR:
20781 {
20782
20783 int32_t indx = ri->d[rINDEX] / 10000;
20784 if ( ((unsigned)indx) > 3)
20785 {
20786 Z_scripterrlog("Invalid Array Index passed to MAPDATA->SideWarpReturnSquare[]: %d\n", indx);
20787 }
20788 else if (mapscr *m = GetMapscr(ri->mapsref))
20789 {
20790 int32_t wrindex = vbound(value/10000, 0, 3);
20791 m->warpreturnc = (m->warpreturnc&~(3<<(8+(indx*2)))) | (wrindex<<(8+(indx*2)));
20792 }
20793 else
20794 {
20795 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","str");
20796 }
20797 break;
20798 }
20799
20800 case MAPDATAFFWIDTH:
20801 {
20802 int32_t indx = (ri->d[rINDEX] / 10000)-1;
20803 if ( indx < 0 || indx > MAXFFCS-1 )
20804 {
20805 Z_scripterrlog("Invalid FFC Index passed to MapData->FFCTileWidth[]: %d\n", indx+1);
20806 }
20807 else if ( (value/10000) < 0 || (value/10000) > 4 )
20808 {
20809 Z_scripterrlog("Invalid WIDTH value passed to MapData->FFCTileWidth[]: %d\n", value/10000);
20810 }
20811 else if (mapscr *m = GetMapscr(ri->mapsref))
20812 {
20813 m->ffTileWidth(indx, (value/10000));
20814 }
20815 else
20816 {
20817 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","FFCTileWidth[]");
20818 }
20819 break;
20820 }
20821
20822 case MAPDATAFFHEIGHT:
20823 {
20824 int32_t indx = (ri->d[rINDEX] / 10000)-1;
20825 if ( indx < 0 || indx > MAXFFCS-1 )
20826 {
20827 Z_scripterrlog("Invalid FFC Index passed to MapData->FFCTileHeight[]: %d\n", indx+1);
20828 }
20829 else if ( (value/10000) < 0 || (value/10000) > 4 )
20830 {
20831 Z_scripterrlog("Invalid WIDTH value passed to MapData->FFCTileHeight[]: %d\n", value/10000);
20832 }
20833 else if (mapscr *m = GetMapscr(ri->mapsref))
20834 {
20835 m->ffTileHeight(indx, (value/10000));
20836 }
20837 else
20838 {
20839 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","FFCTileHeight[]");
20840 }
20841 break;
20842
20843 }
20844
20845 case MAPDATAFFEFFECTWIDTH:
20846 {
20847 int32_t indx = (ri->d[rINDEX] / 10000)-1;
20848 if ( indx < 0 || indx > MAXFFCS-1 )
20849 {
20850 Z_scripterrlog("Invalid FFC Index passed to MapData->FFCEffectWidth[]: %d\n", indx+1);
20851 }
20852 else if ( (value/10000) < 0 )
20853 {
20854 Z_scripterrlog("Invalid WIDTH value passed to MapData->FFCEffectWidth[]: %d\n", value/10000);
20855 }
20856 else if (mapscr *m = GetMapscr(ri->mapsref))
20857 {
20858 m->ffEffectWidth(indx, (value/10000));
20859 }
20860 else
20861 {
20862 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","FFCEffectWidth[]");
20863 }
20864 break;
20865 }
20866
20867 case MAPDATAFFEFFECTHEIGHT:
20868 {
20869 int32_t indx = (ri->d[rINDEX] / 10000)-1;
20870 if ( indx < 0 || indx > MAXFFCS-1 )
20871 {
20872 Z_scripterrlog("Invalid FFC Index passed to MapData->FFCEffectHeight[]: %d\n", indx+1);
20873 }
20874 else if ( (value/10000) < 0 )
20875 {
20876 Z_scripterrlog("Invalid HEIGHT value passed to MapData->FFCEffectHeight[]: %d\n", value/10000);
20877 }
20878 else if (mapscr *m = GetMapscr(ri->mapsref))
20879 {
20880 m->ffEffectHeight(indx, (value/10000));
20881 }
20882 else
20883 {
20884 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","FFCEffectHeight[]");
20885 }
20886 break;
20887 }
20888
20889 case MAPDATAFFLINK: SET_MAPDATA_FFC_INDEX_VBOUND(link, "FFCLink", MAXFFCS-1, 0, MAXFFCS); break; //B, MAXFFCS OF THESE
20890 case MAPDATAFFSCRIPT: SET_MAPDATA_FFC_INDEX_VBOUND(script, "FFCScript", MAXFFCS-1, 0, 255); break; //W, 32 OF THESE
20891
20892 case MAPDATAINTID: //Same form as SetScreenD()
20893 //SetFFCInitD(ffindex, d, value)
20894 {
20895 if (mapscr *m = GetMapscr(ri->mapsref))
20896 {
20897 //int32_t ffindex = ri->d[rINDEX]/10000;
20898 //int32_t d = ri->d[rINDEX2]/10000;
20899 //int32_t v = (value/10000);
20900 int32_t ffid = (ri->d[rINDEX]/10000) -1;
20901 int32_t indx = ri->d[rINDEX2]/10000;
20902
20903 if ( (unsigned)ffid > MAXFFCS-1 )
20904 {
20905 Z_scripterrlog("Invalid FFC id passed to mapdata->FFCInitD[]: %d",ffid);
20906 }
20907 else if ( (unsigned)indx > 7 )
20908 {
20909 Z_scripterrlog("Invalid InitD[] index passed to mapdata->FFCInitD[]: %d",indx);
20910 }
20911 else
20912 {
20913 m->ffcs[ffid].initd[indx] = value;
20914 }
20915 }
20916 else
20917 {
20918 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","SetFFCInitD()");
20919 }
20920 break;
20921 }
20922
20923
20924 //initd //INT32 , 32 OF THESE, EACH WITH 10 INDICES.
20925
20926
20927 case MAPDATAINITA:
20928 //same form as SetScreenD
20929 {
20930 if (mapscr *m = GetMapscr(ri->mapsref))
20931 {//int32_t ffindex = ri->d[rINDEX]/10000;
20932 //int32_t d = ri->d[rINDEX2]/10000;
20933 //int32_t v = (value/10000);
20934 int32_t ffid = (ri->d[rINDEX]/10000) -1;
20935 int32_t indx = ri->d[rINDEX2]/10000;
20936
20937 if ( (unsigned)ffid > MAXFFCS-1 )
20938 {
20939 Z_scripterrlog("Invalid FFC id passed to mapdata->FFCInitD[]: %d",ffid);
20940 }
20941 else if ( (unsigned)indx > 7 )
20942 {
20943 Z_scripterrlog("Invalid InitD[] index passed to mapdata->FFCInitD[]: %d",indx);
20944 }
20945 else
20946 {
20947 m->ffcs[ffid].inita[indx] = value;
20948 }
20949 }
20950 else
20951 {
20952 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","SetFFCInitA()");
20953 }
20954 break;
20955 }
20956
20957 case MAPDATAFFINITIALISED:
20958 {
20959 int32_t indx = ri->d[rINDEX] / 10000;
20960 if(indx < 0 || indx > MAXFFCS-1)
20961 {
20962 Z_scripterrlog("Invalid Index passed to mapdata->%s[]: %d\n", "FFCRunning", indx);
20963 }
20964 else if (mapscr *m = GetMapscr(ri->mapsref))
20965 {
20966 get_script_engine_data(ScriptType::FFC, indx).initialized = (value/10000) ? true : false;
20967 }
20968 else
20969 {
20970 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n", "FFCRunning");
20971 }
20972 }
20973 break;
20974
20975 case MAPDATASCRIPTENTRY: SET_MAPDATA_VAR_INT32(script_entry, "ScriptEntry"); break; //W
20976 case MAPDATASCRIPTOCCUPANCY: SET_MAPDATA_VAR_INT32(script_occupancy, "ScriptOccupancy"); break;//W
20977 case MAPDATASCRIPTEXIT: SET_MAPDATA_VAR_INT32(script_exit, "ExitScript"); break; //W
20978 case MAPDATAOCEANSFX:
20979 {
20980 if (mapscr *m = GetMapscr(ri->mapsref))
20981 {
20982 int32_t v = vbound(value/10000, 0, 255);
20983 if(m == tmpscr && m->oceansfx != v)
20984 {
20985 stop_sfx(m->oceansfx);
20986 m->oceansfx = v;
20987 cont_sfx(m->oceansfx);
20988 }
20989 else m->oceansfx = v;
20990 }
20991 else
20992 {
20993 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","OceanSFX");
20994 }
20995 break;
20996 }
20997 case MAPDATABOSSSFX: SET_MAPDATA_VAR_BYTE(bosssfx, "BossSFX"); break; //B
20998 case MAPDATASECRETSFX: SET_MAPDATA_VAR_BYTE(secretsfx, "SecretSFX"); break; //B
20999 case MAPDATAHOLDUPSFX: SET_MAPDATA_VAR_BYTE(holdupsfx, "ItemSFX"); break; //B
21000 case MAPDATASCREENMIDI:
21001 {
21002 if (mapscr *m = GetMapscr(ri->mapsref))
21003 {
21004 m->screen_midi = vbound((value / 10000)-(MIDIOFFSET_MAPSCR-MIDIOFFSET_ZSCRIPT),-1,32767);
21005 }
21006 else
21007 {
21008 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","MIDI");
21009 }
21010 break;
21011 }
21012 case MAPDATALENSLAYER: SET_MAPDATA_VAR_BYTE(lens_layer, "LensLayer"); break; //B, OLD QUESTS ONLY?
21013
21014
21015 case MAPDATAFLAGS:
21016 {
21017 int32_t flagid = (ri->d[rINDEX])/10000;
21018 //bool valtrue = ( value ? 10000 : 0);
21019 if(mapscr *m = GetMapscr(ri->mapsref))
21020 {
21021 switch(flagid)
21022 {
21023 case 0: m->flags = (value / 10000); break;
21024 case 1: m->flags2 = (value / 10000); break;
21025 case 2: m->flags3 = (value / 10000); break;
21026 case 3: m->flags4 = (value / 10000); break;
21027 case 4: m->flags5 = (value / 10000); break;
21028 case 5: m->flags6 = (value / 10000); break;
21029 case 6: m->flags7 = (value / 10000); break;
21030 case 7: m->flags8 = (value / 10000); break;
21031 case 8: m->flags9 = (value / 10000); break;
21032 case 9: m->flags10 = (value / 10000); break;
21033 default:
21034 {
21035 Z_scripterrlog("Invalid index passed to mapdata->flags[]: %d\n", flagid);
21036 break;
21037 }
21038 }
21039 }
21040 else
21041 {
21042 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","Flags[]");
21043 }
21044 break;
21045 //SET_MAPDATA_BYTE_INDEX //B, 11 OF THESE, flags, flags2-flags10
21046 }
21047
21048 case MAPDATAMISCD:
21049 {
21050 if(mapscr* m = GetMapscr(ri->mapsref))
21051 {
21052 int32_t indx = (ri->d[rINDEX])/10000;
21053 int32_t mi = get_mi(ri->mapsref);
21054 if(mi<0) break;
21055 if( ((unsigned)indx) > 7 )
21056 {
21057 Z_scripterrlog("You were trying to reference an out-of-bounds array index for a screen's D[] array (%ld); valid indices are from 0 to 7.\n", indx);
21058 break;
21059 }
21060 else
21061 {
21062 game->screen_d[mi][indx] = value/10000;
21063 break;
21064 }
21065 }
21066 else
21067 {
21068 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","D[]");
21069 }
21070 break;
21071 }
21072
21073
21074 case MAPDATACOMBODD:
21075 {
21076 80782 int32_t pos = (ri->d[rINDEX])/10000;
21077 80782 int32_t val = (value/10000);
21078
21079
1/2
✓ Branch 0 taken 80782 times.
✗ Branch 1 not taken.
80782 if(mapscr *m = GetMapscr(ri->mapsref))
21080 {
21081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80782 times.
80782 if ( ((unsigned) pos) > 175 )
21082 {
21083 Z_scripterrlog("Invalid [pos] %d used to write to mapdata->ComboD[]\n", pos);
21084 }
21085
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80782 times.
80782 else if ( ((unsigned) val) >= MAXCOMBOS )
21086 {
21087 Z_scripterrlog("Invalid combo ID %d used to write to mapdata->ComboD[]\n", val);
21088 }
21089 else
21090 {
21091 80782 screen_combo_modify_preroutine(m,pos);
21092 80782 m->data[pos]=val;
21093 80782 screen_combo_modify_postroutine(m,pos);
21094 }
21095 80782 }
21096 else
21097 {
21098 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","ComboD[]");
21099 }
21100 }
21101 80782 break;
21102
21103 case MAPDATACOMBOCD:
21104 {
21105 2497 int32_t pos = (ri->d[rINDEX])/10000;
21106 2497 int32_t val = (value/10000); //cset
21107
1/2
✓ Branch 0 taken 2497 times.
✗ Branch 1 not taken.
2497 if(mapscr *m = GetMapscr(ri->mapsref))
21108 {
21109
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2497 times.
2497 if ( ((unsigned) pos) > 175 )
21110 {
21111 Z_scripterrlog("Invalid [pos] %d used to write to mapdata->ComboC[]\n", pos);
21112 }
21113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2497 times.
2497 else if ( ((unsigned) val) >= 15 )
21114 {
21115 Z_scripterrlog("Invalid CSet ID %d used to write to mapdata->ComboC[]\n", val);
21116 }
21117 else
21118 {
21119 2497 screen_combo_modify_preroutine(m,pos);
21120 2497 m->cset[pos]=(val)&15;
21121 2497 screen_combo_modify_postroutine(m,pos);
21122 }
21123 2497 }
21124 else
21125 {
21126 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","ComboC[]");
21127 }
21128 }
21129 2497 break;
21130
21131 case MAPDATACOMBOFD:
21132 {
21133 56174 int32_t pos = (ri->d[rINDEX])/10000;
21134 56174 int32_t val = (value/10000); //flag
21135
1/2
✓ Branch 0 taken 56174 times.
✗ Branch 1 not taken.
56174 if(mapscr *m = GetMapscr(ri->mapsref))
21136 {
21137
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56174 times.
56174 if ( ((unsigned) pos) > 175 )
21138 {
21139 Z_scripterrlog("Invalid [pos] %d used to write to mapdata->ComboF[]\n", pos);
21140 }
21141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56174 times.
56174 else if ( ((unsigned) val) >= 256 )
21142 {
21143 Z_scripterrlog("Invalid Flag ID %d used to write to mapdata->ComboF[]\n", val);
21144 }
21145
21146 else
21147 56174 m->sflag[pos]=(val);
21148 56174 }
21149 else
21150 {
21151 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","ComboF[]");
21152 }
21153 }
21154 56174 break;
21155
21156 case MAPDATACOMBOTD:
21157 {
21158 int32_t pos = (ri->d[rINDEX])/10000;
21159 int32_t val = (value/10000); //type
21160 if(mapscr *m = GetMapscr(ri->mapsref))
21161 {
21162 if ( ((unsigned) pos) > 175 )
21163 {
21164 Z_scripterrlog("Invalid [pos] %d used to write to mapdata->ComboT[]\n", pos);
21165 }
21166 else if ( ((unsigned) val) >= cMAX )
21167 {
21168 Z_scripterrlog("Invalid Type ID %d used to write to mapdata->ComboT[]\n", val);
21169 }
21170 else
21171 {
21172 auto cid = m->data[pos];
21173 screen_combo_modify_pre(cid);
21174 combobuf[cid].type=val;
21175 screen_combo_modify_post(cid);
21176 }
21177 }
21178 else
21179 {
21180 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","ComboT[]");
21181 }
21182 }
21183 break;
21184
21185 case MAPDATACOMBOID:
21186 {
21187 int32_t pos = (ri->d[rINDEX])/10000;
21188 int32_t val = (value/10000); //iflag
21189 if(mapscr *m = GetMapscr(ri->mapsref))
21190 {
21191 if ( ((unsigned) pos) > 175 )
21192 {
21193 Z_scripterrlog("Invalid [pos] %d used to write to mapdata->ComboI[]\n", pos);
21194 }
21195 else if ( ((unsigned) val) >= 256 )
21196 {
21197 Z_scripterrlog("Invalid Flag ID %d used to write to mapdata->ComboI[]\n", val);
21198 }
21199
21200 else
21201 combobuf[m->data[pos]].flag=value/10000;
21202 }
21203 else
21204 {
21205 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","ComboI[]");
21206 }
21207 }
21208 break;
21209
21210 case MAPDATACOMBOSD:
21211 {
21212 int32_t pos = (ri->d[rINDEX])/10000;
21213 int32_t val = (value/10000); //solidity
21214 if(mapscr *m = GetMapscr(ri->mapsref))
21215 {
21216 if ( ((unsigned) pos) > 175 )
21217 {
21218 Z_scripterrlog("Invalid [pos] %d used to write to mapdata->ComboS[]\n", pos);
21219 }
21220 else if ( ((unsigned) val) >= 16 )
21221 {
21222 Z_scripterrlog("Invalid Solidity %d used to write to mapdata->ComboS[]\n", val);
21223 }
21224
21225 else
21226 {
21227 combobuf[m->data[pos]].walk &= ~0x0F;
21228 combobuf[m->data[pos]].walk |= (val)&0x0F;
21229 }
21230 }
21231 else
21232 {
21233 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","ComboS[]");
21234 }
21235 }
21236 break;
21237
21238 case MAPDATACOMBOED:
21239 {
21240 int32_t pos = (ri->d[rINDEX])/10000;
21241 int32_t val = (value/10000); //solidity
21242 if(mapscr *m = GetMapscr(ri->mapsref))
21243 {
21244 if ( ((unsigned) pos) > 175 )
21245 {
21246 Z_scripterrlog("Invalid [pos] %d used to write to mapdata->ComboE[]\n", pos);
21247 }
21248 else if ( ((unsigned) val) >= 16 )
21249 {
21250 Z_scripterrlog("Invalid Solidity %d used to write to mapdata->ComboE[]\n", val);
21251 }
21252
21253 else
21254 {
21255 combobuf[m->data[pos]].walk &= ~0xF0;
21256 combobuf[m->data[pos]].walk |= ((val)&0x0F)<<4;
21257 }
21258 }
21259 else
21260 {
21261 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","ComboE[]");
21262 }
21263 }
21264 break;
21265
21266 case MAPDATASCREENSTATED:
21267 {
21268 if(mapscr* m = GetMapscr(ri->mapsref))
21269 {
21270 int32_t mi = get_mi(ri->mapsref);
21271 if(mi<0) break;
21272 (value)?setmapflag(mi, 1<<((ri->d[rINDEX])/10000)) : unsetmapflag(mi, 1 << ((ri->d[rINDEX]) / 10000));
21273 }
21274 else
21275 {
21276 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","State[]");
21277 }
21278 }
21279 break;
21280 case MAPDATAEXSTATED:
21281 {
21282 if(mapscr* m = GetMapscr(ri->mapsref))
21283 {
21284 int32_t mi = get_mi(ri->mapsref);
21285 if(mi<0) break;
21286 (value)?setxmapflag(mi, 1<<((ri->d[rINDEX])/10000)) : unsetxmapflag(mi, 1 << ((ri->d[rINDEX]) / 10000));
21287 }
21288 else
21289 {
21290 Z_scripterrlog("Script attempted to use a mapdata->%s on an invalid pointer\n","State[]");
21291 }
21292 break;
21293 }
21294 case MAPDATALENSSHOWS:
21295 {
21296 int ind = ri->d[rINDEX]/10000;
21297 if(ind < 0 || ind > 6)
21298 Z_scripterrlog("Bad index mapdata->LensShows[%d]\n",ind);
21299 else if(mapscr *m = GetMapscr(ri->mapsref))
21300 {
21301 SETFLAG(m->lens_show, 1<<ind, value);
21302 if(value) m->lens_hide &= ~(1<<ind);
21303 }
21304 else Z_scripterrlog("mapdata->LensShows[] pointer (%d) is either invalid or uninitialised.\n", ri->mapsref);
21305 break;
21306 }
21307 case MAPDATALENSHIDES:
21308 {
21309 int ind = ri->d[rINDEX]/10000;
21310 if(ind < 0 || ind > 6)
21311 Z_scripterrlog("Bad index mapdata->LensHides[%d]\n",ind);
21312 else if(mapscr *m = GetMapscr(ri->mapsref))
21313 {
21314 SETFLAG(m->lens_hide, 1<<ind, value);
21315 if(value) m->lens_show &= ~(1<<ind);
21316 }
21317 else Z_scripterrlog("mapdata->LensHides[] pointer (%d) is either invalid or uninitialised.\n", ri->mapsref);
21318 break;
21319 }
21320
21321 ///----------------------------------------------------------------------------------------------------//
21322 //shopdata sd-> Variables
21323
21324 case SHOPDATAITEM:
21325 {
21326
21327 int32_t ref = ri->shopsref;
21328 bool isInfo = ( ref > NUMSHOPS && ref <= NUMINFOSHOPS );
21329 int32_t indx = ri->d[rINDEX] / 10000;
21330 if ( indx < 0 || indx > 2 )
21331 {
21332 Z_scripterrlog("Invalid Array Index passed to shopdata->%s: %d\n", indx, "Item");
21333 break;
21334 }
21335 else
21336 {
21337 if ( isInfo )
21338 {
21339 Z_scripterrlog("Attempted to write an 'item' to an infoshop, using shop ID: %d\n", ri->shopsref);
21340 break;
21341 }
21342 else
21343 {
21344 QMisc.shop[ref].item[indx] = (byte)(vbound((value/10000), 0, 255));
21345 break;
21346 }
21347 }
21348 }
21349 break;
21350 //SET_SHOPDATA_VAR_INDEX(item, "Item", 2); break;
21351 case SHOPDATAHASITEM:
21352 {
21353
21354 int32_t ref = ri->shopsref;
21355 bool isInfo = ( ref > NUMSHOPS && ref <= NUMINFOSHOPS );
21356 int32_t indx = ri->d[rINDEX] / 10000;
21357 if ( indx < 0 || indx > 2 )
21358 {
21359 Z_scripterrlog("Invalid Array Index passed to shopdata->%s: %d\n", indx, "HasItem");
21360 break;
21361 }
21362 else
21363 {
21364 if ( isInfo )
21365 {
21366 Z_scripterrlog("Attempted to write 'hasitem' to an infoshop, using shop ID: %d\n", ri->shopsref);
21367 break;
21368 }
21369 else
21370 {
21371 QMisc.shop[ref].hasitem[indx] = (byte)(vbound((value/10000), 0, 255)); break;
21372 }
21373 }
21374 }
21375 break;
21376 //SET_SHOPDATA_VAR_INDEX(hasitem, "HasItem", 2); break;
21377 case SHOPDATAPRICE:
21378 {
21379
21380 int32_t ref = ri->shopsref;
21381 bool isInfo = ( ref > NUMSHOPS && ref <= NUMINFOSHOPS );
21382 int32_t indx = ri->d[rINDEX] / 10000;
21383 if ( indx < 0 || indx > 2 )
21384 {
21385 Z_scripterrlog("Invalid Array Index passed to shopdata->%s: %d\n", indx, "Price");
21386 break;
21387 }
21388 else
21389 {
21390 if ( isInfo )
21391 {
21392 QMisc.info[ref].price[indx] = (word)(vbound((value/10000), 0, 65535));
21393 break;
21394 }
21395 else
21396 {
21397 QMisc.shop[ref].price[indx] = (word)(vbound((value/10000), 0, 65535));
21398 break;
21399 }
21400 }
21401 }
21402 //SET_SHOPDATA_VAR_INDEX(price, "Price", 2); break;
21403 //Pay for info
21404 case SHOPDATASTRING:
21405 {
21406 {
21407 if ( ri->shopsref < NUMSHOPS || ri->shopsref > NUMINFOSHOPS )
21408 {
21409 Z_scripterrlog("Invalid Info Shop ID passed to shopdata->String[]: %d\n", ri->shopsref);
21410 break;
21411 }
21412 else
21413 {
21414 int32_t ref = ri->shopsref;
21415 bool isInfo = ( ref > NUMSHOPS && ref <= NUMINFOSHOPS );
21416 int32_t indx = ri->d[rINDEX] / 10000;
21417 if ( indx < 0 || indx > 2 )
21418 {
21419 Z_scripterrlog("Invalid Array Index passed to shopdata->%s: %d\n", indx, "HasItem");
21420 break;
21421 }
21422 else
21423 {
21424 if ( isInfo )
21425 {
21426 QMisc.info[ref].str[indx] = (word)(vbound((value/10000), 0, 32767));
21427 break;
21428 }
21429 else
21430 {
21431 QMisc.shop[ref].str[indx] = (word)(vbound((value/10000), 0, 32767));
21432 break;
21433 }
21434 }
21435
21436
21437 }
21438
21439 //GET_SHOPDATA_VAR_INDEX(str, String, 2); break;
21440 } break;
21441 }
21442
21443 ///----------------------------------------------------------------------------------------------------//
21444 //dmapdata dmd-> Variables
21445 case DMAPDATAMAP: //byte
21446 {
21447 DMaps[ri->dmapsref].map = ((byte)(value / 10000)) - 1; break;
21448 }
21449 case DMAPDATALEVEL: //word
21450 {
21451 DMaps[ri->dmapsref].level = ((word)(value / 10000)); break;
21452 }
21453 case DMAPDATAOFFSET: //char
21454 {
21455 DMaps[ri->dmapsref].xoff = ((char)(value / 10000)); break;
21456 }
21457 case DMAPDATACOMPASS: //byte
21458 {
21459 DMaps[ri->dmapsref].compass = ((byte)(value / 10000)); break;
21460 }
21461 case DMAPDATAPALETTE: //word
21462 {
21463 DMaps[ri->dmapsref].color= ((word)(value / 10000));
21464 if(ri->dmapsref == currdmap)
21465 {
21466 loadlvlpal(DMaps[ri->dmapsref].color);
21467 currcset = DMaps[ri->dmapsref].color;
21468 }
21469 break;
21470 }
21471 case DMAPDATAMIDI: //byte
21472 {
21473 DMaps[ri->dmapsref].midi = ((byte)((value / 10000)+MIDIOFFSET_DMAP)); break;
21474 }
21475 case DMAPDATACONTINUE: //byte
21476 {
21477 DMaps[ri->dmapsref].cont = ((byte)(value / 10000)); break;
21478 }
21479 case DMAPDATATYPE: //byte
21480 {
21481 DMaps[ri->dmapsref].type = (((byte)(value / 10000))&dmfTYPE) | (DMaps[ri->dmapsref].type&~dmfTYPE); break;
21482 }
21483 case DMAPSCRIPT: //byte
21484 {
21485 FFScript::deallocateAllArrays(ScriptType::DMap, ri->dmapsref);
21486 DMaps[ri->dmapsref].script = vbound((value / 10000),0,NUMSCRIPTSDMAP-1); break;
21487 }
21488 case DMAPDATASIDEVIEW: //byte, treat as bool
21489 {
21490 DMaps[ri->dmapsref].sideview = ((value) ? 1 : 0); break;
21491 }
21492 case DMAPDATAGRID: //byte[8] --array
21493 {
21494 int32_t indx = ri->d[rINDEX] / 10000;
21495 if ( indx < 0 || indx > 7 )
21496 {
21497 Z_scripterrlog("Invalid index supplied to dmapdata->Grid[]: %d\n", indx); break;
21498 }
21499 else
21500 {
21501 DMaps[ri->dmapsref].grid[indx] = ((byte)(value / 10000)); break;
21502 }
21503 }
21504 case DMAPINITD:
21505 {
21506 int32_t indx = ri->d[rINDEX] / 10000;
21507 if ( indx < 0 || indx > 7 )
21508 {
21509 Z_scripterrlog("Invalid index supplied to dmapdata->InitD[]: %d\n", indx); break;
21510 }
21511 else
21512 {
21513 DMaps[ri->dmapsref].initD[indx] = value; break;
21514 }
21515 }
21516 case DMAPDATAMINIMAPTILE: //word - two of these, so let's do MinimapTile[2]
21517 {
21518 int32_t indx = ri->d[rINDEX] / 10000;
21519 switch(indx)
21520 {
21521 case 0: { DMaps[ri->dmapsref].minimap_1_tile = ((word)(value / 10000)); break; }
21522 case 1: { DMaps[ri->dmapsref].minimap_2_tile = ((word)(value / 10000)); break; }
21523 default:
21524 {
21525 Z_scripterrlog("Invalid index supplied to dmapdata->MiniMapTile[]: %d\n", indx);
21526 break;
21527 }
21528 }
21529 break;
21530 }
21531 case DMAPDATAMINIMAPCSET: //byte - two of these, so let's do MinimapCSet[2]
21532 {
21533 int32_t indx = ri->d[rINDEX] / 10000;
21534 switch(indx)
21535 {
21536 case 0: { DMaps[ri->dmapsref].minimap_1_cset= ((byte)(value / 10000)); break; }
21537 case 1: { DMaps[ri->dmapsref].minimap_2_cset= ((byte)(value / 10000)); break; }
21538 default:
21539 {
21540 Z_scripterrlog("Invalid index supplied to dmapdata->MiniMapCSet[]: %d\n", indx);
21541 break;
21542 }
21543 }
21544 break;
21545 }
21546 case DMAPDATALARGEMAPTILE: //word -- two of these, so let's to LargemapTile[2]
21547 {
21548 int32_t indx = ri->d[rINDEX] / 10000;
21549 switch(indx)
21550 {
21551 case 0: { DMaps[ri->dmapsref].largemap_1_tile = ((word)(value / 10000)); break; }
21552 case 1: { DMaps[ri->dmapsref].largemap_2_tile = ((word)(value / 10000)); break; }
21553 default:
21554 {
21555 Z_scripterrlog("Invalid index supplied to dmapdata->LargeMapTile[]: %d\n", indx);
21556 break;
21557 }
21558 }
21559 break;
21560 }
21561 case DMAPDATALARGEMAPCSET: //word -- two of these, so let's to LargemaCSet[2]
21562 {
21563 int32_t indx = ri->d[rINDEX] / 10000;
21564 switch(indx)
21565 {
21566 case 0: { DMaps[ri->dmapsref].largemap_1_cset= ((byte)(value / 10000)); break; }
21567 case 1: { DMaps[ri->dmapsref].largemap_2_cset= ((byte)(value / 10000)); break; }
21568 default:
21569 {
21570 Z_scripterrlog("Invalid index supplied to dmapdata->LargeMapCSet[]: %d\n", indx);
21571 break;
21572 }
21573 }
21574 break;
21575 }
21576 case DMAPDATAMUISCTRACK: //byte
21577 {
21578 DMaps[ri->dmapsref].tmusictrack= ((byte)(value / 10000)); break;
21579 }
21580 case DMAPDATASUBSCRA: //byte, active subscreen
21581 {
21582 bool changed = DMaps[ri->dmapsref].active_subscreen != ((byte)(value / 10000));
21583 DMaps[ri->dmapsref].active_subscreen= ((byte)(value / 10000));
21584 if(changed&&ri->dmapsref==currdmap)
21585 update_subscreens();
21586 break;
21587 }
21588 case DMAPDATASUBSCRP: //byte, passive subscreen
21589 {
21590 bool changed = DMaps[ri->dmapsref].passive_subscreen != ((byte)(value / 10000));
21591 DMaps[ri->dmapsref].passive_subscreen= ((byte)(value / 10000));
21592 if(changed&&ri->dmapsref==currdmap)
21593 update_subscreens();
21594 break;
21595 }
21596 case DMAPDATADISABLEDITEMS: //byte[MAXITEMS]
21597 {
21598 int32_t indx = ri->d[rINDEX] / 10000;
21599 if ( indx < 0 || indx > (MAXITEMS-1) )
21600 {
21601 Z_scripterrlog("Invalid index supplied to dmapdata->Grid[]: %d\n", indx); break;
21602 }
21603 else
21604 {
21605 DMaps[ri->dmapsref].disableditems[indx] = ((byte)(value / 10000)); break;
21606 }
21607 }
21608
21609 case DMAPDATAFLAGARR: //int32_t
21610 {
21611 int32_t indx = ri->d[rINDEX] / 10000;
21612 if ( ((unsigned)indx) > 31 )
21613 {
21614 Z_scripterrlog("Invalid index supplied to dmapdata->Flags[]: %d\n", indx);
21615 break;
21616 }
21617 if ( value ) DMaps[ri->dmapsref].flags |= (1<<indx);
21618 else DMaps[ri->dmapsref].flags &= ~(1<<indx);
21619 break;
21620 }
21621 case DMAPDATAFLAGS: //int32_t
21622 {
21623 DMaps[ri->dmapsref].flags = (value / 10000); break;
21624 }
21625 case DMAPDATAMIRRDMAP:
21626 {
21627 DMaps[ri->dmapsref].mirrorDMap = vbound(value / 10000, -1, MAXDMAPS); break;
21628 }
21629 case DMAPDATALOOPSTART:
21630 {
21631 DMaps[ri->dmapsref].tmusic_loop_start = value;
21632 if (ri->dmapsref == currdmap)
21633 {
21634 if (FFCore.doing_dmap_enh_music(currdmap))
21635 {
21636 zcmusic_set_loop(zcmusic, double(DMaps[currdmap].tmusic_loop_start / 10000.0), double(DMaps[currdmap].tmusic_loop_end / 10000.0));
21637 }
21638 }
21639 break;
21640 }
21641 case DMAPDATALOOPEND:
21642 {
21643 DMaps[ri->dmapsref].tmusic_loop_end = value;
21644 if (ri->dmapsref == currdmap)
21645 {
21646 if (FFCore.doing_dmap_enh_music(currdmap))
21647 {
21648 zcmusic_set_loop(zcmusic, double(DMaps[currdmap].tmusic_loop_start / 10000.0), double(DMaps[currdmap].tmusic_loop_end / 10000.0));
21649 }
21650 }
21651 break;
21652 }
21653 case DMAPDATAXFADEIN:
21654 {
21655 DMaps[ri->dmapsref].tmusic_xfade_in = (value / 10000);
21656 break;
21657 }
21658 case DMAPDATAXFADEOUT:
21659 {
21660 DMaps[ri->dmapsref].tmusic_xfade_out = (value / 10000);
21661 if (DMaps[currdmap].tmusic[0]!=0 && strcmp(DMaps[ri->dmapsref].tmusic, zcmusic->filename) == 0)
21662 {
21663 zcmusic->fadeoutframes = (value / 10000);
21664 }
21665 break;
21666 }
21667 case MUSICUPDATECOND:
21668 {
21669 FFCore.music_update_cond = vbound(value / 10000, 0, 255);
21670 break;
21671 }
21672 case MUSICUPDATEFLAGS:
21673 {
21674 int32_t indx = ri->d[rINDEX] / 10000;
21675 if (indx < 0 || indx > 1)
21676 {
21677 Z_scripterrlog("Invalid Index passed to Audio->MusicRefreshFlags[]: %d\n", indx);
21678 break;
21679 }
21680 SETFLAG(FFCore.music_update_flags, 1 << indx, value);
21681 break;
21682 }
21683 case DMAPDATAASUBSCRIPT: //byte
21684 {
21685 FFScript::deallocateAllArrays(ScriptType::ActiveSubscreen, ri->dmapsref);
21686 DMaps[ri->dmapsref].active_sub_script = vbound((value / 10000),0,NUMSCRIPTSDMAP-1); break;
21687 }
21688 case DMAPDATAMAPSCRIPT: //byte
21689 {
21690 3225 FFScript::deallocateAllArrays(ScriptType::OnMap, ri->dmapsref);
21691 3225 DMaps[ri->dmapsref].onmap_script = vbound((value / 10000),0,NUMSCRIPTSDMAP-1); break;
21692 }
21693 case DMAPDATAPSUBSCRIPT: //byte
21694 {
21695 FFScript::deallocateAllArrays(ScriptType::PassiveSubscreen, ri->dmapsref);
21696 word val = vbound((value / 10000),0,NUMSCRIPTSDMAP-1);
21697 if (FFCore.doscript(ScriptType::PassiveSubscreen) && ri->dmapsref == currdmap && val == DMaps[ri->dmapsref].passive_sub_script)
21698 break;
21699 DMaps[ri->dmapsref].passive_sub_script = val;
21700 if(ri->dmapsref == currdmap)
21701 {
21702 FFCore.doscript(ScriptType::PassiveSubscreen) = val != 0;
21703 };
21704 break;
21705 }
21706 case DMAPDATASUBINITD:
21707 {
21708 int32_t indx = ri->d[rINDEX] / 10000;
21709 if ( indx < 0 || indx > 7 )
21710 {
21711 Z_scripterrlog("Invalid index supplied to dmapdata->SubInitD[]: %d\n", indx); break;
21712 }
21713 else
21714 {
21715 DMaps[ri->dmapsref].sub_initD[indx] = value; break;
21716 }
21717 }
21718
21719 case DMAPDATAMAPINITD:
21720 {
21721 int32_t indx = ri->d[rINDEX] / 10000;
21722 if ( indx < 0 || indx > 7 )
21723 {
21724 Z_scripterrlog("Invalid index supplied to dmapdata->MapInitD[]: %d\n", indx); break;
21725 }
21726 else
21727 {
21728 DMaps[ri->dmapsref].onmap_initD[indx] = value; break;
21729 }
21730 }
21731
21732 case DMAPDATACHARTED:
21733 {
21734 int32_t scr = ri->d[rINDEX] / 10000;
21735 if(ri->dmapsref >= MAXDMAPS)
21736 {
21737 Z_scripterrlog("Invalid DMap reference used for dmapdata->Charted[]: %d\n", ri->dmapsref);
21738 }
21739 // else if((DMaps[get_currdmap()].type&dmfTYPE) == dmOVERW)
21740 // {
21741 // Z_scripterrlog("dmapdata->Charted[] cannot presently be used on Overworld-type dmaps\n");
21742 // }
21743 else if(((unsigned)(scr)) > 127)
21744 {
21745 Z_scripterrlog("Invalid index supplied to dmapdata->Charted[]: %d\n", scr);
21746 }
21747 else
21748 {
21749 int32_t col = (scr&15)-(DMaps[ri->dmapsref].type==dmOVERW ? 0 : DMaps[ri->dmapsref].xoff);
21750 if((DMaps[ri->dmapsref].type&dmfTYPE)!=dmOVERW ? (((unsigned)col) > 7) : (((unsigned)col) > 15))
21751 break; //Out-of-bounds; don't attempt write!
21752 int32_t di = (ri->dmapsref << 7) + (scr & 0x7F);
21753 game->bmaps[di] = (value/10000)&0x8F;
21754 }
21755 break;
21756 }
21757 //case DMAPDATAGRAVITY: //unimplemented
21758 //case DMAPDATAJUMPLAYER: //unimplemented
21759
21760 ///----------------------------------------------------------------------------------------------------//
21761 //messagedata msgd-> Variables
21762
21763
21764 case MESSAGEDATANEXT: //W
21765 {
21766 int32_t ID = ri->zmsgref;
21767
21768 if(BC::checkMessage(ID, "messagedata->Next") != SH::_NoError)
21769 break;
21770 else
21771 MsgStrings[ID].nextstring = vbound((value/10000), 0, (msg_count-1));
21772 break;
21773 }
21774
21775 case MESSAGEDATATILE: //W
21776 {
21777 int32_t ID = ri->zmsgref;
21778
21779 if(BC::checkMessage(ID, "messagedata->Tile") != SH::_NoError)
21780 break;
21781 else
21782 MsgStrings[ID].tile = vbound((value/10000), 0, (NEWMAXTILES));
21783 break;
21784 }
21785
21786 case MESSAGEDATACSET: //b
21787 {
21788 int32_t ID = ri->zmsgref;
21789
21790 if(BC::checkMessage(ID, "messagedata->CSet") != SH::_NoError)
21791 break;
21792 else
21793 MsgStrings[ID].cset = ((byte)vbound((value/10000), 0, 15));
21794 break;
21795 }
21796 case MESSAGEDATATRANS: //BOOL
21797 {
21798 int32_t ID = ri->zmsgref;
21799
21800 if(BC::checkMessage(ID, "messagedata->Transparent") != SH::_NoError)
21801 break;
21802 else
21803 (MsgStrings[ID].trans) = ((value)?true:false);
21804 break;
21805 }
21806 case MESSAGEDATAFONT: //B
21807 {
21808 int32_t ID = ri->zmsgref;
21809
21810 if(BC::checkMessage(ID, "messagedata->Font") != SH::_NoError)
21811 break;
21812 else
21813 MsgStrings[ID].font = ((byte)vbound((value/10000), 0, 255));
21814 break;
21815 }
21816 case MESSAGEDATAX: //SHORT
21817 {
21818 int32_t ID = ri->zmsgref;
21819
21820 if(BC::checkMessage(ID, "messagedata->X") != SH::_NoError)
21821 break;
21822 else
21823 MsgStrings[ID].x = ((int16_t)vbound((value/10000), SHRT_MIN, SHRT_MAX));
21824 break;
21825 }
21826 case MESSAGEDATAY: //SHORT
21827 {
21828 int32_t ID = ri->zmsgref;
21829
21830 if(BC::checkMessage(ID, "messagedata->Y") != SH::_NoError)
21831 break;
21832 else
21833 MsgStrings[ID].y = ((int16_t)vbound((value/10000), SHRT_MIN, SHRT_MAX));
21834 break;
21835 }
21836 case MESSAGEDATAW: //UNSIGNED SHORT
21837 {
21838 int32_t ID = ri->zmsgref;
21839
21840 if(BC::checkMessage(ID, "messagedata->Width") != SH::_NoError)
21841 break;
21842 else
21843 MsgStrings[ID].w = ((uint16_t)vbound((value/10000), 0, USHRT_MAX));
21844 break;
21845 }
21846 case MESSAGEDATAH: //UNSIGNED SHORT
21847 {
21848 int32_t ID = ri->zmsgref;
21849
21850 if(BC::checkMessage(ID, "messagedata->Height") != SH::_NoError)
21851 break;
21852 else
21853 MsgStrings[ID].h = ((uint16_t)vbound((value/10000), 0, USHRT_MAX));
21854 break;
21855 }
21856 case MESSAGEDATASFX: //BYTE
21857 {
21858 int32_t ID = ri->zmsgref;
21859
21860 if(BC::checkMessage(ID, "messagedata->Sound") != SH::_NoError)
21861 break;
21862 else
21863 MsgStrings[ID].sfx = ((byte)vbound((value/10000), 0, 255));
21864 break;
21865 }
21866 case MESSAGEDATALISTPOS: //WORD
21867 {
21868 int32_t ID = ri->zmsgref;
21869
21870 if(BC::checkMessage(ID, "messagedata->ListPosition") != SH::_NoError)
21871 break;
21872 else
21873 MsgStrings[ID].listpos = vbound((value/10000), 1, (msg_count-1));
21874 break;
21875 }
21876 case MESSAGEDATAVSPACE: //BYTE
21877 {
21878 int32_t ID = ri->zmsgref;
21879
21880 if(BC::checkMessage(ID, "messagedata->VSpace") != SH::_NoError)
21881 break;
21882 else
21883 MsgStrings[ID].vspace = ((byte)vbound((value/10000), 0, 255));
21884 break;
21885 }
21886 case MESSAGEDATAHSPACE: //BYTE
21887 {
21888 int32_t ID = ri->zmsgref;
21889
21890 if(BC::checkMessage(ID, "messagedata->HSpace") != SH::_NoError)
21891 break;
21892 else
21893 MsgStrings[ID].hspace = ((byte)vbound((value/10000), 0, 255));
21894 break;
21895 }
21896 case MESSAGEDATAFLAGS: //BYTE
21897 {
21898 int32_t ID = ri->zmsgref;
21899
21900 if(BC::checkMessage(ID, "messagedata->Flags") != SH::_NoError)
21901 break;
21902 else
21903 MsgStrings[ID].stringflags = ((byte)vbound((value/10000), 0, 255));
21904 break;
21905 }
21906 case MESSAGEDATAMARGINS: //BYTE, 4
21907 {
21908 int32_t indx = ri->d[rINDEX] / 10000;
21909 if ( indx < 0 || indx > 3 )
21910 {
21911 Z_scripterrlog("Invalid index supplied to messagedata->Margins[]: %d\n", indx);
21912 break;
21913 }
21914 int32_t ID = ri->zmsgref;
21915
21916 if(BC::checkMessage(ID, "messagedata->Margins[]") != SH::_NoError)
21917 break;
21918 else
21919 MsgStrings[ID].margins[indx] = ((byte)vbound((value/10000), 0, 255));
21920 break;
21921 }
21922 case MESSAGEDATAPORTTILE: //INT
21923 {
21924 int32_t ID = ri->zmsgref;
21925
21926 if(BC::checkMessage(ID, "messagedata->PortraitTile") != SH::_NoError)
21927 break;
21928 else
21929 MsgStrings[ID].portrait_tile = vbound((value/10000), 0, (NEWMAXTILES));
21930 break;
21931 }
21932 case MESSAGEDATAPORTCSET: //BYTE
21933 {
21934 int32_t ID = ri->zmsgref;
21935
21936 if(BC::checkMessage(ID, "messagedata->PortraitCSet") != SH::_NoError)
21937 break;
21938 else
21939 MsgStrings[ID].portrait_cset = ((byte)vbound((value/10000), 0, 15));
21940 break;
21941 }
21942 case MESSAGEDATAPORTX: //BYTE
21943 {
21944 int32_t ID = ri->zmsgref;
21945
21946 if(BC::checkMessage(ID, "messagedata->PortraitX") != SH::_NoError)
21947 break;
21948 else
21949 MsgStrings[ID].portrait_x = ((byte)vbound((value/10000), 0, 255));
21950 break;
21951 }
21952 case MESSAGEDATAPORTY: //BYTE
21953 {
21954 int32_t ID = ri->zmsgref;
21955
21956 if(BC::checkMessage(ID, "messagedata->PortraitY") != SH::_NoError)
21957 break;
21958 else
21959 MsgStrings[ID].portrait_y = ((byte)vbound((value/10000), 0, 255));
21960 break;
21961 }
21962 case MESSAGEDATAPORTWID: //BYTE
21963 {
21964 int32_t ID = ri->zmsgref;
21965
21966 if(BC::checkMessage(ID, "messagedata->PortraitTileWidth") != SH::_NoError)
21967 break;
21968 else
21969 MsgStrings[ID].portrait_tw = ((byte)vbound((value/10000), 0, 16));
21970 break;
21971 }
21972 case MESSAGEDATAPORTHEI: //BYTE
21973 {
21974 int32_t ID = ri->zmsgref;
21975
21976 if(BC::checkMessage(ID, "messagedata->PortraitTileHeight") != SH::_NoError)
21977 break;
21978 else
21979 MsgStrings[ID].portrait_th = ((byte)vbound((value/10000), 0, 14));
21980 break;
21981 }
21982 case MESSAGEDATAFLAGSARR: //BOOL, 7
21983 {
21984 int32_t indx = ri->d[rINDEX] / 10000;
21985 int32_t ID = ri->zmsgref;
21986
21987 if(BC::checkMessage(ID, "messagedata->Flags[]") != SH::_NoError)
21988 break;
21989 else
21990 {
21991 switch(indx)
21992 {
21993 case 0:
21994 (value) ? (MsgStrings[ID].stringflags)|=STRINGFLAG_WRAP : (MsgStrings[ID].stringflags)&= ~STRINGFLAG_WRAP;
21995 break;
21996 case 1:
21997 (value) ? (MsgStrings[ID].stringflags)|=STRINGFLAG_CONT : (MsgStrings[ID].stringflags)&= ~STRINGFLAG_CONT;
21998 break;
21999 case 2: //Not implemented
22000 //(value) ? (MsgStrings[ID].stringflags)|=STRINGFLAG_CENTER : (MsgStrings[ID].stringflags)&= ~STRINGFLAG_CENTER;
22001 break;
22002 case 3: //Not implemented
22003 //(value) ? (MsgStrings[ID].stringflags)|=STRINGFLAG_RIGHT : (MsgStrings[ID].stringflags)&= ~STRINGFLAG_RIGHT;
22004 break;
22005 case 4:
22006 (value) ? (MsgStrings[ID].stringflags)|=STRINGFLAG_FULLTILE : (MsgStrings[ID].stringflags)&= ~STRINGFLAG_FULLTILE;
22007 break;
22008 case 5:
22009 (value) ? (MsgStrings[ID].stringflags)|=STRINGFLAG_TRANS_BG : (MsgStrings[ID].stringflags)&= ~STRINGFLAG_TRANS_BG;
22010 break;
22011 case 6:
22012 (value) ? (MsgStrings[ID].stringflags)|=STRINGFLAG_TRANS_FG : (MsgStrings[ID].stringflags)&= ~STRINGFLAG_TRANS_FG;
22013 break;
22014 default:
22015 Z_scripterrlog("Invalid index supplied to messagedata->Flags[]: %d\n", indx);
22016 break;
22017 }
22018 }
22019 break;
22020 }
22021
22022
22023
22024
22025 ///----------------------------------------------------------------------------------------------------//
22026 //combodata cd-> Setter Variables
22027 //newcombo
22028 #define SET_COMBO_VAR_INT(member, str) \
22029 { \
22030 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
22031 { \
22032 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
22033 } \
22034 else \
22035 { \
22036 combobuf[ri->combosref].member = vbound((value / 10000),0,214747); \
22037 } \
22038 } \
22039
22040 #define SET_COMBO_VAR_DWORD(member, str) \
22041 { \
22042 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
22043 { \
22044 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
22045 } \
22046 else \
22047 { \
22048 combobuf[ri->combosref].member = vbound((value / 10000),0,32767); \
22049 } \
22050 } \
22051
22052 #define SET_COMBO_VAR_BYTE(member, str) \
22053 { \
22054 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
22055 { \
22056 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
22057 } \
22058 else \
22059 { \
22060 combobuf[ri->combosref].member = vbound((value / 10000),0,255); \
22061 } \
22062 } \
22063
22064 #define SET_COMBO_VAR_INDEX(member, str, indexbound) \
22065 { \
22066 int32_t indx = ri->d[rINDEX] / 10000; \
22067 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
22068 { \
22069 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
22070 } \
22071 else if ( indx < 0 || indx >= indexbound ) \
22072 { \
22073 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, str); \
22074 } \
22075 else \
22076 { \
22077 combobuf[ri->combosref].member[indx] = vbound((value / 10000),0,214747); \
22078 } \
22079 }
22080
22081 #define SET_COMBO_VAR_INDEX2(member, str, indexbound, low, high) \
22082 { \
22083 int32_t indx = ri->d[rINDEX] / 10000; \
22084 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
22085 { \
22086 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
22087 } \
22088 else if ( indx < 0 || indx >= indexbound ) \
22089 { \
22090 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, str); \
22091 } \
22092 else \
22093 { \
22094 combobuf[ri->combosref].member[indx] = vbound((value / 10000),low,high); \
22095 } \
22096 }
22097
22098 #define SET_COMBO_BYTE_INDEX(member, str, indexbound) \
22099 { \
22100 int32_t indx = ri->d[rINDEX] / 10000; \
22101 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
22102 { \
22103 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
22104 } \
22105 else if ( indx < 0 || indx >= indexbound ) \
22106 { \
22107 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, str); \
22108 } \
22109 else \
22110 { \
22111 combobuf[ri->combosref].member[indx] = vbound((value / 10000),0,255); \
22112 } \
22113 }
22114
22115 #define SET_COMBO_FLAG(member, str) \
22116 { \
22117 int32_t flag = (value/10000); \
22118 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
22119 { \
22120 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
22121 } \
22122 else \
22123 { \
22124 if ( flag != 0 ) \
22125 { \
22126 combobuf[ri->combosref].member|=flag; \
22127 } \
22128 else combobuf[ri->combosref].member|= ~flag; \
22129 } \
22130 } \
22131
22132 //comboclass
22133 #define SET_COMBOCLASS_VAR_INT(member, str) \
22134 { \
22135 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
22136 { \
22137 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
22138 } \
22139 else \
22140 { \
22141 combo_class_buf[combobuf[ri->combosref].type].member = vbound((value / 10000),0,214747); \
22142 } \
22143 } \
22144
22145 #define SET_COMBOCLASS_VAR_DWORD(member, str) \
22146 { \
22147 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
22148 { \
22149 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
22150 } \
22151 else \
22152 { \
22153 combo_class_buf[combobuf[ri->combosref].type].member = vbound((value / 10000),0,32767); \
22154 } \
22155 } \
22156
22157 #define SET_COMBOCLASS_VAR_BYTE(member, str) \
22158 { \
22159 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
22160 { \
22161 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
22162 } \
22163 else \
22164 { \
22165 combo_class_buf[combobuf[ri->combosref].type].member = vbound((value / 10000),0,255); \
22166 } \
22167 } \
22168
22169 #define SET_COMBOCLASS_VAR_INDEX(member, str, indexbound) \
22170 { \
22171 int32_t indx = ri->d[rINDEX] / 10000; \
22172 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
22173 { \
22174 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
22175 } \
22176 else if ( indx < 0 || indx > indexbound ) \
22177 { \
22178 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, str); \
22179 } \
22180 else \
22181 { \
22182 combo_class_buf[combobuf[ri->combosref].type].member[indx] = vbound((value / 10000),0,214747); \
22183 } \
22184 }
22185
22186 #define SET_COMBOCLASS_BYTE_INDEX(member, str, indexbound) \
22187 { \
22188 int32_t indx = ri->d[rINDEX] / 10000; \
22189 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
22190 { \
22191 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
22192 } \
22193 else if ( indx < 0 || indx > indexbound ) \
22194 { \
22195 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, str); \
22196 } \
22197 else \
22198 { \
22199 combo_class_buf[combobuf[ri->combosref].type].member[indx] = vbound((value / 10000),0,255); \
22200 } \
22201 }
22202
22203 #define SET_COMBOCLASS_FLAG(member, str) \
22204 { \
22205 int32_t flag = (value/10000); \
22206 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) ) \
22207 { \
22208 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), str); \
22209 } \
22210 else \
22211 { \
22212 if ( flag != 0 ) \
22213 { \
22214 combo_class_buf[combobuf[ri->combosref].type].member|=flag; \
22215 } \
22216 else combo_class_buf[combobuf[ri->combosref].type].member|= ~flag; \
22217 } \
22218 } \
22219
22220 //NEWCOMBO STRUCT
22221 case COMBODTILE: SET_COMBO_VAR_INT(tile, "Tile"); break; //word
22222 case COMBODOTILE:
22223 {
22224 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22225 {
22226 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "OriginalTile");
22227 }
22228 else
22229 {
22230 newcombo& cdata = combobuf[ri->combosref];
22231 cdata.o_tile = vbound((value / 10000),0,NEWMAXTILES);
22232 if(get_qr(qr_NEW_COMBO_ANIMATION))
22233 {
22234 cdata.tile = cdata.o_tile + ((1+cdata.skipanim)*cdata.cur_frame);
22235 if(int32_t rowoffset = TILEROW(cdata.tile)-TILEROW(cdata.o_tile))
22236 {
22237 cdata.tile += cdata.skipanimy * rowoffset * TILES_PER_ROW;
22238 }
22239 }
22240 }
22241 break;
22242 }
22243 case COMBODFRAME: SET_COMBO_VAR_BYTE(cur_frame, "Frame"); break; //char
22244 case COMBODACLK: SET_COMBO_VAR_BYTE(aclk, "AClk"); break; //char
22245 case COMBODATASCRIPT: SET_COMBO_VAR_DWORD(script, "Script"); break; //word
22246 case COMBODASPEED: SET_COMBO_VAR_BYTE(speed, "ASpeed"); break; //char
22247 case COMBODFLIP: SET_COMBO_VAR_BYTE(flip, "Flip"); break; //char
22248 case COMBODWALK:
22249 {
22250 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22251 {
22252 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "Walk");
22253 }
22254 else
22255 {
22256 combobuf[ri->combosref].walk &= ~0x0F;
22257 combobuf[ri->combosref].walk |= (value / 10000)&0x0F;
22258 }
22259 break;
22260 }
22261 case COMBODEFFECT:
22262 {
22263 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22264 {
22265 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "Effect");
22266 }
22267 else
22268 {
22269 combobuf[ri->combosref].walk &= ~0xF0;
22270 combobuf[ri->combosref].walk |= ((value / 10000)&0x0F)<<4;
22271 }
22272 break;
22273 }
22274 case COMBODTYPE:
22275 {
22276 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22277 {
22278 Z_scripterrlog("Invalid Combo ID passed to combodata->Type: %d\n", (ri->combosref*10000));
22279 }
22280 else
22281 {
22282 screen_combo_modify_pre(ri->combosref);
22283 combobuf[ri->combosref].type = vbound((value / 10000),0,255);
22284 screen_combo_modify_post(ri->combosref);
22285 }
22286 break;
22287 }
22288 case COMBODCSET:
22289 {
22290 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22291 {
22292 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "CSet2");
22293 }
22294 else
22295 {
22296 int8_t v = vbound(value, -8, 7);
22297 combobuf[ri->combosref].csets &= ~0xF;
22298 combobuf[ri->combosref].csets |= v;
22299 }
22300 break;
22301 }
22302 case COMBODCSET2FLAGS:
22303 {
22304 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22305 {
22306 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "CSet2Flags");
22307 }
22308 else
22309 {
22310 combobuf[ri->combosref].csets &= 0xF;
22311 combobuf[ri->combosref].csets |= (value&0xF)<<4;
22312 }
22313 break;
22314 }
22315 case COMBODFOO: break; //W
22316 case COMBODFRAMES: SET_COMBO_VAR_BYTE(frames, "Frames"); break; //C
22317 case COMBODNEXTD: SET_COMBO_VAR_DWORD(speed, "NextData"); break; //W
22318 case COMBODNEXTC: SET_COMBO_VAR_BYTE(nextcombo, "NextCSet"); break; //C
22319 case COMBODFLAG: SET_COMBO_VAR_BYTE(nextcset, "Flag"); break; //C
22320 case COMBODSKIPANIM: SET_COMBO_VAR_BYTE(skipanim, "SkipAnim"); break; //C
22321 case COMBODNEXTTIMER: SET_COMBO_VAR_DWORD(nexttimer, "NextTimer"); break; //W
22322 case COMBODAKIMANIMY: SET_COMBO_VAR_BYTE(skipanimy, "SkipAnimY"); break; //C
22323 case COMBODANIMFLAGS: SET_COMBO_VAR_BYTE(animflags, "AnimFlags"); break; //C
22324 case COMBODEXPANSION: SET_COMBO_BYTE_INDEX(expansion, "Expansion[]", 6); break; //C , 6 INDICES
22325 case COMBODATTRIBUTES:
22326 {
22327 int32_t indx = ri->d[rINDEX] / 10000;
22328 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22329 {
22330 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "Attributes[]");
22331 }
22332 else if ( indx < 0 || indx > 4 )
22333 {
22334 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, "Attributes[]");
22335 }
22336 else
22337 {
22338 combobuf[ri->combosref].attributes[indx] = value;
22339 }
22340 }break;
22341 //case COMBODATAINITD: SET_COMBO_VAR_INDEX(initd, "InitD[]", 2); break; //LONG, 4 INDICES, INDIVIDUAL VALUES
22342 case COMBODATAINITD:
22343 {
22344 int32_t indx = ri->d[rINDEX] / 10000;
22345 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22346 {
22347 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "InitD[]");
22348 }
22349 else if ( ((unsigned)indx) > 2 )
22350 {
22351 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, "InitD[]");
22352 }
22353 else
22354 {
22355 combobuf[ri->combosref].initd[indx] = (value * ( get_qr(qr_COMBODATA_INITD_MULT_TENK) ? 10000 : 1));
22356 }
22357 break;
22358 }
22359
22360
22361 case COMBODATTRIBYTES: SET_COMBO_VAR_INDEX(attribytes, "Attribytes[]", 8); break; //LONG, 4 INDICES, INDIVIDUAL VALUES
22362 case COMBODATTRISHORTS: SET_COMBO_VAR_INDEX2(attrishorts, "Attrishorts[]", 8, -32768, 32767); break; //LONG, 4 INDICES, INDIVIDUAL VALUES
22363 case COMBODUSRFLAGARR:
22364 {
22365 int32_t indx = ri->d[rINDEX] / 10000;
22366 if (ri->combosref < 0 || ri->combosref >(MAXCOMBOS - 1))
22367 {
22368 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", "Flags[]", (ri->combosref * 10000));
22369 }
22370 else if (((unsigned)indx) > 15)
22371 {
22372 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", "Flags[]", indx);
22373 }
22374 else
22375 {
22376 SETFLAG(combobuf[ri->combosref].usrflags, 1 << indx, value);
22377 }
22378 break;
22379 }
22380 case COMBODGENFLAGARR:
22381 {
22382 int32_t indx = ri->d[rINDEX] / 10000;
22383 if (ri->combosref < 0 || ri->combosref >(MAXCOMBOS - 1))
22384 {
22385 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", "GenFlags[]", (ri->combosref * 10000));
22386 }
22387 else if (((unsigned)indx) > 0)
22388 {
22389 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", "GenFlags[]", indx);
22390 }
22391 else
22392 {
22393 SETFLAG(combobuf[ri->combosref].genflags, 1 << indx, value);
22394 }
22395 break;
22396 }
22397 case COMBODUSRFLAGS: SET_COMBO_VAR_INT(usrflags, "UserFlags"); break; //LONG
22398 case COMBODTRIGGERFLAGS: SET_COMBO_VAR_INDEX(triggerflags, "TriggerFlags[]", 6); break; //LONG 3 INDICES AS FLAGSETS
22399 case COMBODTRIGGERFLAGS2:
22400 {
22401 int32_t indx = ri->d[rINDEX] / 10000;
22402 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22403 {
22404 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TrigFlags[]");
22405 }
22406 else if ( unsigned(indx) >= 32*6 )
22407 {
22408 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, "TrigFlags[]");
22409 }
22410 else
22411 {
22412 SETFLAG(combobuf[ri->combosref].triggerflags[indx/32],1<<(indx%32),value);
22413 }
22414 break;
22415 }
22416 case COMBODTRIGGERBUTTON:
22417 {
22418 int32_t indx = ri->d[rINDEX] / 10000;
22419 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22420 {
22421 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerButton[]");
22422 }
22423 else if ( unsigned(indx) >= 8 )
22424 {
22425 Z_scripterrlog("Invalid Array Index passed to combodata->%s: %d\n", indx, "TriggerButton[]");
22426 }
22427 else
22428 {
22429 SETFLAG(combobuf[ri->combosref].triggerbtn,1<<indx,value);
22430 }
22431 break;
22432 }
22433 case COMBODTRIGGERITEM:
22434 {
22435 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22436 {
22437 Z_scripterrlog("Invalueid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerItem");
22438 }
22439 else combobuf[ri->combosref].triggeritem = vbound(value/10000,0,255);
22440 break;
22441 }
22442 case COMBODTRIGGERTIMER:
22443 {
22444 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22445 {
22446 Z_scripterrlog("Invalueid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerTimer");
22447 }
22448 else combobuf[ri->combosref].trigtimer = vbound(value/10000,0,255);
22449 break;
22450 }
22451 case COMBODTRIGGERSFX:
22452 {
22453 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22454 {
22455 Z_scripterrlog("Invalueid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerSFX");
22456 }
22457 else combobuf[ri->combosref].trigsfx = vbound(value/10000,0,255);
22458 break;
22459 }
22460 case COMBODTRIGGERCHANGECMB:
22461 {
22462 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22463 {
22464 Z_scripterrlog("Invalueid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerChange");
22465 }
22466 else combobuf[ri->combosref].trigchange = vbound(value/10000,-65535,65535);
22467 break;
22468 }
22469 case COMBODTRIGGERPROX:
22470 {
22471 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22472 {
22473 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerProximity");
22474 }
22475 else combobuf[ri->combosref].trigprox = vbound(value/10000,0,65535);
22476 break;
22477 }
22478 case COMBODTRIGGERLIGHTBEAM:
22479 {
22480 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22481 {
22482 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerLightBeam");
22483 }
22484 else combobuf[ri->combosref].triglbeam = vbound(value/10000,0,32);
22485 break;
22486 }
22487 case COMBODTRIGGERCTR:
22488 {
22489 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22490 {
22491 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerCounter");
22492 }
22493 else combobuf[ri->combosref].trigctr = vbound(value/10000, 0, MAX_COUNTERS-1);
22494 break;
22495 }
22496 case COMBODTRIGGERCTRAMNT:
22497 {
22498 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22499 {
22500 Z_scripterrlog("Invalid Combo ID passed to combodata->%s: %d\n", (ri->combosref*10000), "TriggerCtrAmount");
22501 }
22502 else combobuf[ri->combosref].trigctramnt = vbound(value/10000, -65535, 65535);
22503 break;
22504 }
22505
22506 case COMBODTRIGGERCOOLDOWN:
22507 {
22508 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22509 {
22510 Z_scripterrlog("Invalid Combo ID passed to combodata->TriggerCooldown: %d\n", (ri->combosref*10000));
22511 }
22512 else combobuf[ri->combosref].trigcooldown = vbound(value/10000, 0, 255);
22513 break;
22514 }
22515 case COMBODTRIGGERCOPYCAT:
22516 {
22517 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22518 {
22519 Z_scripterrlog("Invalid Combo ID passed to combodata->TriggerCopycat: %d\n", (ri->combosref*10000));
22520 }
22521 else combobuf[ri->combosref].trigcopycat = vbound(value/10000, 0, 255);
22522 break;
22523 }
22524 case COMBODTRIGITEMPICKUP:
22525 {
22526 const int32_t allowed_pflags = ipHOLDUP | ipTIMER | ipSECRETS | ipCANGRAB;
22527 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22528 {
22529 Z_scripterrlog("Invalid Combo ID passed to combodata->TriggerSpawnItemPickup: %d\n", (ri->combosref*10000));
22530 }
22531 else combobuf[ri->combosref].spawnip = (value/10000)&allowed_pflags;
22532 break;
22533 }
22534 case COMBODTRIGEXSTATE:
22535 {
22536 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22537 {
22538 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigExState: %d\n", (ri->combosref*10000));
22539 }
22540 else combobuf[ri->combosref].exstate = vbound(value/10000, -1, 31);
22541 break;
22542 }
22543 case COMBODTRIGSPAWNENEMY:
22544 {
22545 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22546 {
22547 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigSpawnEnemy: %d\n", (ri->combosref*10000));
22548 }
22549 else combobuf[ri->combosref].spawnenemy = vbound(value/10000, 0, 511);
22550 break;
22551 }
22552 case COMBODTRIGSPAWNITEM:
22553 {
22554 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22555 {
22556 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigSpawnItem: %d\n", (ri->combosref*10000));
22557 }
22558 else combobuf[ri->combosref].spawnitem = vbound(value/10000, -255, 255);
22559 break;
22560 }
22561 case COMBODTRIGCSETCHANGE:
22562 {
22563 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22564 {
22565 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigCSetChange: %d\n", (ri->combosref*10000));
22566 }
22567 else combobuf[ri->combosref].trigcschange = vbound(value/10000, -15, 15);
22568 break;
22569 }
22570 case COMBODLIFTGFXCOMBO:
22571 {
22572 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22573 {
22574 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftGFXCombo: %d\n", (ri->combosref*10000));
22575 }
22576 else combobuf[ri->combosref].liftcmb = vbound(value/10000, 0, MAXCOMBOS);
22577 break;
22578 }
22579 case COMBODLIFTGFXCCSET:
22580 {
22581 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22582 {
22583 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftGFXCSet: %d\n", (ri->combosref*10000));
22584 }
22585 else combobuf[ri->combosref].liftcs = vbound(value/10000, 0, 13);
22586 break;
22587 }
22588 case COMBODLIFTUNDERCMB:
22589 {
22590 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22591 {
22592 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftUnderCombo: %d\n", (ri->combosref*10000));
22593 }
22594 else combobuf[ri->combosref].liftundercmb = vbound(value/10000, 0, MAXCOMBOS);
22595 break;
22596 }
22597 case COMBODLIFTUNDERCS:
22598 {
22599 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22600 {
22601 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftUnderCSet: %d\n", (ri->combosref*10000));
22602 }
22603 else combobuf[ri->combosref].liftundercs = vbound(value/10000, 0, 13);
22604 break;
22605 }
22606 case COMBODLIFTDAMAGE:
22607 {
22608 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22609 {
22610 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftDamage: %d\n", (ri->combosref*10000));
22611 }
22612 else combobuf[ri->combosref].liftdmg = vbound(value/10000, 0, 255);
22613 break;
22614 }
22615 case COMBODLIFTLEVEL:
22616 {
22617 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22618 {
22619 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftLevel: %d\n", (ri->combosref*10000));
22620 }
22621 else combobuf[ri->combosref].liftlvl = vbound(value/10000, 0, 255);
22622 break;
22623 }
22624 case COMBODLIFTITEM:
22625 {
22626 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22627 {
22628 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftItem: %d\n", (ri->combosref*10000));
22629 }
22630 else combobuf[ri->combosref].liftitm = vbound(value/10000, 0, 255);
22631 break;
22632 }
22633 case COMBODLIFTFLAGS:
22634 {
22635 int32_t indx = ri->d[rINDEX] / 10000;
22636 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22637 {
22638 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftFlags[]: %d\n", (ri->combosref*10000));
22639 break;
22640 }
22641 if ( unsigned(indx) > 7 )
22642 {
22643 Z_scripterrlog("Invalid index supplied to combodata->LiftFlags[]: %d\n", indx);
22644 break;
22645 }
22646 SETFLAG(combobuf[ri->combosref].liftflags, (1<<indx), value);
22647 break;
22648 }
22649 case COMBODLIFTGFXTYPE:
22650 {
22651 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22652 {
22653 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftGFXType: %d\n", (ri->combosref*10000));
22654 }
22655 else combobuf[ri->combosref].liftgfx = vbound(value/10000, 0, 2);
22656 break;
22657 }
22658 case COMBODLIFTGFXSPRITE:
22659 {
22660 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22661 {
22662 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftGFXSprite: %d\n", (ri->combosref*10000));
22663 }
22664 else combobuf[ri->combosref].liftsprite = vbound(value/10000, 0, 255);
22665 break;
22666 }
22667 case COMBODLIFTSFX:
22668 {
22669 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22670 {
22671 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftSFX: %d\n", (ri->combosref*10000));
22672 }
22673 else combobuf[ri->combosref].liftsfx = vbound(value/10000, 0, 255);
22674 break;
22675 }
22676 case COMBODLIFTBREAKSPRITE:
22677 {
22678 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22679 {
22680 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftBreakSprite: %d\n", (ri->combosref*10000));
22681 }
22682 else combobuf[ri->combosref].liftbreaksprite = vbound(value/10000, -4, 255);
22683 break;
22684 }
22685 case COMBODLIFTBREAKSFX:
22686 {
22687 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22688 {
22689 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftBreakSFX: %d\n", (ri->combosref*10000));
22690 }
22691 else combobuf[ri->combosref].liftbreaksfx = vbound(value/10000, 0, 255);
22692 break;
22693 }
22694 case COMBODLIFTHEIGHT:
22695 {
22696 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22697 {
22698 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftHeight: %d\n", (ri->combosref*10000));
22699 }
22700 else combobuf[ri->combosref].lifthei = vbound(value/10000, 0, 255);
22701 break;
22702 }
22703 case COMBODLIFTTIME:
22704 {
22705 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22706 {
22707 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftTime: %d\n", (ri->combosref*10000));
22708 }
22709 else combobuf[ri->combosref].lifttime = vbound(value/10000, 0, 255);
22710 break;
22711 }
22712 case COMBODLIFTWEAPONITEM:
22713 {
22714 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22715 {
22716 Z_scripterrlog("Invalid Combo ID passed to combodata->LiftWeaponItem: %d\n", (ri->combosref*10000));
22717 }
22718 else combobuf[ri->combosref].lift_parent_item = vbound(value/10000, 0, 255);
22719 break;
22720 }
22721 case COMBODTRIGGERLSTATE:
22722 {
22723 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22724 {
22725 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigLevelState: %d\n", (ri->combosref*10000));
22726 }
22727 else combobuf[ri->combosref].trig_lstate = vbound(value/10000, 0, 31);
22728 break;
22729 }
22730 case COMBODTRIGGERGSTATE:
22731 {
22732 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22733 {
22734 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigGlobalState: %d\n", (ri->combosref*10000));
22735 }
22736 else combobuf[ri->combosref].trig_gstate = vbound(value/10000, 0, 255);
22737 break;
22738 }
22739 case COMBODTRIGGERGROUP:
22740 {
22741 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22742 {
22743 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigGroup: %d\n", (ri->combosref*10000));
22744 }
22745 else combobuf[ri->combosref].trig_group = vbound(value/10000, 0, 255);
22746 break;
22747 }
22748 case COMBODTRIGGERGROUPVAL:
22749 {
22750 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22751 {
22752 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigGroupVal: %d\n", (ri->combosref*10000));
22753 }
22754 else combobuf[ri->combosref].trig_group_val = vbound(value/10000, 0, 65535);
22755 break;
22756 }
22757 case COMBODTRIGGERGTIMER:
22758 {
22759 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22760 {
22761 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigGStateTimer: %d\n", (ri->combosref*10000));
22762 }
22763 else combobuf[ri->combosref].trig_statetime = vbound(value/10000, 0, 214748);
22764 break;
22765 }
22766 case COMBODTRIGGERGENSCRIPT:
22767 {
22768 if(ri->combosref < 0 || ri->combosref > (MAXCOMBOS-1) )
22769 {
22770 Z_scripterrlog("Invalid Combo ID passed to combodata->TrigGenScript: %d\n", (ri->combosref*10000));
22771 }
22772 else combobuf[ri->combosref].trig_genscr = vbound(value/10000, 0, 65535);
22773 break;
22774 }
22775 case COMBODTRIGGERLEVEL: SET_COMBO_VAR_INT(triggerlevel, "TriggerLevel"); break; //LONG
22776
22777
22778
22779
22780
22781 //COMBOCLASS STRUCT
22782 //case COMBODNAME: //CHAR[64], STRING
22783 case COMBODBLOCKNPC: SET_COMBOCLASS_VAR_BYTE(block_enemies, "BlockNPC"); break; //C
22784 case COMBODBLOCKHOLE: SET_COMBOCLASS_VAR_BYTE(block_hole, "BlockHole"); break; //C
22785 case COMBODBLOCKTRIG: SET_COMBOCLASS_VAR_BYTE(block_trigger, "BlockTrigger"); break; //C
22786 case COMBODBLOCKWEAPON: SET_COMBOCLASS_BYTE_INDEX(block_weapon, "BlockWeapon[]", 32); break; //C, 32 INDICES
22787 case COMBODCONVXSPEED: SET_COMBOCLASS_VAR_DWORD(conveyor_x_speed, "ConveyorSpeedX"); break; //SHORT
22788 case COMBODCONVYSPEED: SET_COMBOCLASS_VAR_DWORD(conveyor_y_speed, "ConveyorSpeedY"); break; //SHORT
22789 case COMBODSPAWNNPC: SET_COMBOCLASS_VAR_DWORD(create_enemy, "SpawnNPC"); break; //W
22790 case COMBODSPAWNNPCWHEN: SET_COMBOCLASS_VAR_BYTE(create_enemy_when, "SpawnNPCWhen"); break; //C
22791 case COMBODSPAWNNPCCHANGE: SET_COMBOCLASS_VAR_INT(create_enemy_change, "SpawnNPCChange"); break; //LONG
22792 case COMBODDIRCHANGETYPE: SET_COMBOCLASS_VAR_BYTE(directional_change_type, "DirChange"); break; //C
22793 case COMBODDISTANCECHANGETILES: SET_COMBOCLASS_VAR_INT(distance_change_tiles, "DistanceChangeTiles"); break; //LONG
22794 case COMBODDIVEITEM: SET_COMBOCLASS_VAR_DWORD(dive_item, "DiveItem"); break; //SHORT
22795 case COMBODDOCK: SET_COMBOCLASS_VAR_BYTE(dock, "Dock"); break; //C
22796 case COMBODFAIRY: SET_COMBOCLASS_VAR_BYTE(fairy, "Fairy"); break; //C
22797 case COMBODFFATTRCHANGE: SET_COMBOCLASS_VAR_BYTE(ff_combo_attr_change, "FFCAttributeChange"); break; //C
22798 case COMBODFOORDECOTILE: SET_COMBOCLASS_VAR_INT(foot_decorations_tile, "DecorationTile"); break; //LONG
22799 case COMBODFOORDECOTYPE: SET_COMBOCLASS_VAR_BYTE(foot_decorations_type, "DecorationType"); break; //C
22800 case COMBODHOOKSHOTPOINT: SET_COMBOCLASS_VAR_BYTE(hookshot_grab_point, "Hookshot"); break; //C
22801 case COMBODLADDERPASS: SET_COMBOCLASS_VAR_BYTE(ladder_pass, "Ladder"); break; //C
22802 case COMBODLOCKBLOCK: SET_COMBOCLASS_VAR_BYTE(lock_block_type, "LockBlock"); break; //C
22803 case COMBODLOCKBLOCKCHANGE: SET_COMBOCLASS_VAR_INT(lock_block_change, "LockBlockChange"); break; //LONG
22804 case COMBODMAGICMIRROR: SET_COMBOCLASS_VAR_BYTE(magic_mirror_type, "Mirror"); break; //C
22805 case COMBODMODHPAMOUNT: SET_COMBOCLASS_VAR_DWORD(modify_hp_amount, "DamageAmount"); break; //SHORT
22806 case COMBODMODHPDELAY: SET_COMBOCLASS_VAR_BYTE(modify_hp_delay, "DamageDelay"); break; //C
22807 case COMBODMODHPTYPE: SET_COMBOCLASS_VAR_BYTE(modify_hp_type, "DamageType"); break; //C
22808 case COMBODNMODMPAMOUNT: SET_COMBOCLASS_VAR_DWORD(modify_mp_amount, "MagicAmount"); break; //SHORT
22809 case COMBODMODMPDELAY: SET_COMBOCLASS_VAR_BYTE(modify_mp_delay, "MagicDelay"); break; //C
22810 case COMBODMODMPTYPE: SET_COMBOCLASS_VAR_BYTE(modify_mp_type, "MagicType"); break; //C
22811 case COMBODNOPUSHBLOCK: SET_COMBOCLASS_VAR_BYTE(no_push_blocks, "NoPushBlocks"); break; //C
22812 case COMBODOVERHEAD: SET_COMBOCLASS_VAR_BYTE(overhead, "Overhead"); break; //C
22813 case COMBODPLACENPC: SET_COMBOCLASS_VAR_BYTE(place_enemy, "PlaceNPC"); break; //C
22814 case COMBODPUSHDIR: SET_COMBOCLASS_VAR_BYTE(push_direction, "PushDir"); break; //C
22815 case COMBODPUSHWAIT: SET_COMBOCLASS_VAR_BYTE(push_wait, "PushDelay"); break; //C
22816 case COMBODPUSHHEAVY: SET_COMBOCLASS_VAR_BYTE(push_weight, "PushHeavy"); break; //C
22817 case COMBODPUSHED: SET_COMBOCLASS_VAR_BYTE(pushed, "Pushed"); break; //C
22818 case COMBODRAFT: SET_COMBOCLASS_VAR_BYTE(raft, "Raft"); break; //C
22819 case COMBODRESETROOM: SET_COMBOCLASS_VAR_BYTE(reset_room, "ResetRoom"); break; //C
22820 case COMBODSAVEPOINTTYPE: SET_COMBOCLASS_VAR_BYTE(save_point_type, "SavePoint"); break; //C
22821 case COMBODSCREENFREEZETYPE: SET_COMBOCLASS_VAR_BYTE(screen_freeze_type, "FreezeScreen"); break; //C
22822 case COMBODSECRETCOMBO: SET_COMBOCLASS_VAR_BYTE(secret_combo, "SecretCombo"); break; //C
22823 case COMBODSINGULAR: SET_COMBOCLASS_VAR_BYTE(singular, "Singular"); break; //C
22824 case COMBODSLOWWALK: SET_COMBOCLASS_VAR_BYTE(slow_movement, "SlowWalk"); break; //C
22825 case COMBODSTATUETYPE: SET_COMBOCLASS_VAR_BYTE(statue_type, "Statue"); break; //C
22826 case COMBODSTEPTYPE: SET_COMBOCLASS_VAR_BYTE(step_type, "Step"); break; //C
22827 case COMBODSTEPCHANGEINTO: SET_COMBOCLASS_VAR_INT(step_change_to, "StepChange"); break; //LONG
22828 case COMBODSTRIKEWEAPONS: SET_COMBOCLASS_BYTE_INDEX(strike_weapons, "Strike[]", 32); break; //BYTE, 32 INDICES.
22829 case COMBODSTRIKEREMNANTS: SET_COMBOCLASS_VAR_INT(strike_remnants, "StrikeRemnants"); break; //LONG
22830 case COMBODSTRIKEREMNANTSTYPE: SET_COMBOCLASS_VAR_BYTE(strike_remnants_type, "StrikeRemnantsType"); break; //C
22831 case COMBODSTRIKECHANGE: SET_COMBOCLASS_VAR_INT(strike_change, "StrikeChange"); break; //LONG
22832 case COMBODSTRIKEITEM: SET_COMBOCLASS_VAR_DWORD(strike_item, "StrikeItem"); break; //SHORT
22833 case COMBODTOUCHITEM: SET_COMBOCLASS_VAR_DWORD(touch_item, "TouchItem"); break; //SHORT
22834 case COMBODTOUCHSTAIRS: SET_COMBOCLASS_VAR_BYTE(touch_stairs, "TouchStairs"); break; //C
22835 case COMBODTRIGGERTYPE: SET_COMBOCLASS_VAR_BYTE(trigger_type, "TriggerType"); break; //C
22836 case COMBODTRIGGERSENS: SET_COMBOCLASS_VAR_BYTE(trigger_sensitive, "TriggerSensitivity"); break; //C
22837 case COMBODWARPTYPE: SET_COMBOCLASS_VAR_BYTE(warp_type, "Warp"); break; //C
22838 case COMBODWARPSENS: SET_COMBOCLASS_VAR_BYTE(warp_sensitive, "WarpSensitivity"); break; //C
22839 case COMBODWARPDIRECT: SET_COMBOCLASS_VAR_BYTE(warp_direct, "WarpDirect"); break; //C
22840 case COMBODWARPLOCATION: SET_COMBOCLASS_VAR_BYTE(warp_location, "WarpLocation"); break; //C
22841 case COMBODWATER: SET_COMBOCLASS_VAR_BYTE(water, "Liquid"); break; //C
22842 case COMBODWHISTLE: SET_COMBOCLASS_VAR_BYTE(whistle, "Whistle"); break; //C
22843 case COMBODWINGAME: SET_COMBOCLASS_VAR_BYTE(win_game, "WinGame"); break; //C
22844 case COMBODBLOCKWPNLEVEL: SET_COMBOCLASS_VAR_BYTE(block_weapon_lvl, "BlockWeaponLevel"); break; //C
22845
22846
22847
22848 ///----------------------------------------------------------------------------------------------------//
22849 //npcdata nd-> Variables
22850
22851 #define SET_NPCDATA_VAR_INT(member, str) \
22852 { \
22853 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
22854 { \
22855 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", (ri->npcdataref*10000), str); \
22856 } \
22857 else \
22858 { \
22859 guysbuf[ri->npcdataref].member = vbound((value / 10000),0,214747); \
22860 } \
22861 } \
22862
22863 #define SET_NPCDATA_VAR_DWORD(member, str) \
22864 { \
22865 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
22866 { \
22867 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", (ri->npcdataref*10000), str); \
22868 } \
22869 else \
22870 { \
22871 guysbuf[ri->npcdataref].member = vbound((value / 10000),0,32767); \
22872 } \
22873 } \
22874
22875 #define SET_NPCDATA_VAR_BYTE(member, str) \
22876 { \
22877 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
22878 { \
22879 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", (ri->npcdataref*10000), str); \
22880 } \
22881 else \
22882 { \
22883 guysbuf[ri->npcdataref].member = vbound((value / 10000),0,255); \
22884 } \
22885 } \
22886
22887 #define SET_NPCDATA_VAR_INDEX(member, str, indexbound) \
22888 { \
22889 int32_t indx = ri->d[rINDEX] / 10000; \
22890 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
22891 { \
22892 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", (ri->npcdataref*10000), str); \
22893 } \
22894 else if ( (unsigned)indx > indexbound ) \
22895 { \
22896 Z_scripterrlog("Invalid Array Index passed to npcdata->%s: %d\n", indx, str); \
22897 } \
22898 else \
22899 { \
22900 guysbuf[ri->npcdataref].member[indx] = vbound((value / 10000),0,214747); \
22901 } \
22902 }
22903
22904 #define SET_NPCDATA_BYTE_INDEX(member, str, indexbound) \
22905 { \
22906 int32_t indx = ri->d[rINDEX] / 10000; \
22907 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
22908 { \
22909 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", (ri->npcdataref*10000), str); \
22910 } \
22911 else if ( (unsigned)indx > indexbound ) \
22912 { \
22913 Z_scripterrlog("Invalid Array Index passed to npcdata->%s: %d\n", indx, str); \
22914 } \
22915 else \
22916 { \
22917 guysbuf[ri->npcdataref].member[indx] = vbound((value / 10000),0,255); \
22918 } \
22919 }
22920
22921 #define SET_NPCDATA_FLAG(member, str) \
22922 { \
22923 int32_t flag = (value/10000); \
22924 if( (unsigned) ri->npcdataref > (MAXNPCS-1) ) \
22925 { \
22926 Z_scripterrlog("Invalid NPC ID passed to npcdata->%s: %d\n", (ri->npcdataref*10000), str); \
22927 } \
22928 else \
22929 { \
22930 if ( flag ) \
22931 { \
22932 guysbuf[ri->npcdataref].member|=flag; \
22933 } \
22934 else guysbuf[ri->npcdataref].member|= ~flag; \
22935 } \
22936 } \
22937
22938 case NPCDATATILE: SET_NPCDATA_VAR_BYTE(tile, "Tile"); break;
22939 case NPCDATAWIDTH: SET_NPCDATA_VAR_BYTE(width, "Width"); break;
22940 case NPCDATAHEIGHT: SET_NPCDATA_VAR_BYTE(height, "Height"); break;
22941 case NPCDATAFLAGS: SET_NPCDATA_VAR_DWORD(flags, "Flags"); break; //16 b its
22942 case NPCDATAFLAGS2: SET_NPCDATA_VAR_DWORD(flags2, "Flags2"); break; //16 bits
22943 case NPCDATASTILE: SET_NPCDATA_VAR_BYTE(s_tile, "STile"); break;
22944 case NPCDATASWIDTH: SET_NPCDATA_VAR_BYTE(s_width, "SWidth"); break;
22945 case NPCDATASHEIGHT: SET_NPCDATA_VAR_BYTE(s_height, "SHeight"); break;
22946 case NPCDATAETILE: SET_NPCDATA_VAR_INT(e_tile, "ExTile"); break;
22947 case NPCDATAEWIDTH: SET_NPCDATA_VAR_BYTE(e_width, "ExWidth"); break;
22948 case NPCDATASCRIPT: SET_NPCDATA_VAR_BYTE(script, "Script"); break;
22949 case NPCDATAEHEIGHT: SET_NPCDATA_VAR_BYTE(e_height, "ExHeight"); break;
22950 case NPCDATAHP: SET_NPCDATA_VAR_DWORD(hp, "HP"); break;
22951 case NPCDATAFAMILY: SET_NPCDATA_VAR_DWORD(family, "Family"); break;
22952 case NPCDATACSET: SET_NPCDATA_VAR_DWORD(cset, "CSet"); break;
22953 case NPCDATAANIM: SET_NPCDATA_VAR_DWORD(anim, "Anim"); break;
22954 case NPCDATAEANIM: SET_NPCDATA_VAR_DWORD(e_anim, "ExAnim"); break;
22955 case NPCDATAFRAMERATE: SET_NPCDATA_VAR_DWORD(frate, "Framerate"); break;
22956 case NPCDATAEFRAMERATE: SET_NPCDATA_VAR_DWORD(e_frate, "ExFramerate"); break;
22957 case NPCDATATOUCHDAMAGE: SET_NPCDATA_VAR_DWORD(dp, "TouchDamage"); break;
22958 case NPCDATAWEAPONDAMAGE: SET_NPCDATA_VAR_DWORD(wdp, "WeaponDamage"); break;
22959 case NPCDATAWEAPON: SET_NPCDATA_VAR_DWORD(weapon, "Weapon"); break;
22960 case NPCDATARANDOM: SET_NPCDATA_VAR_DWORD(rate, "Random"); break;
22961 case NPCDATAHALT: SET_NPCDATA_VAR_DWORD(hrate, "Haltrate"); break;
22962 case NPCDATASTEP: SET_NPCDATA_VAR_DWORD(step, "Step"); break;
22963 case NPCDATAHOMING: SET_NPCDATA_VAR_DWORD(homing, "Homing"); break;
22964 case NPCDATAHUNGER: SET_NPCDATA_VAR_DWORD(grumble, "Hunger"); break;
22965 case NPCDATADROPSET: SET_NPCDATA_VAR_DWORD(item_set, "Dropset"); break;
22966 case NPCDATABGSFX: SET_NPCDATA_VAR_DWORD(bgsfx, "BGSFX"); break;
22967 case NPCDATADEATHSFX: SET_NPCDATA_VAR_BYTE(deadsfx, "DeathSFX"); break;
22968 case NPCDATAHITSFX: SET_NPCDATA_VAR_BYTE(hitsfx, "HitSFX"); break;
22969 case NPCDATAXOFS: SET_NPCDATA_VAR_INT(xofs, "DrawXOffset"); break;
22970 case NPCDATAYOFS: SET_NPCDATA_VAR_INT(yofs, "DrawYOffset"); break;
22971 case NPCDATAZOFS: SET_NPCDATA_VAR_INT(zofs, "DrawZOffset"); break;
22972 case NPCDATAHXOFS: SET_NPCDATA_VAR_INT(hxofs, "HitXOffset"); break;
22973 case NPCDATAHYOFS: SET_NPCDATA_VAR_INT(hyofs, "HitYOffset"); break;
22974 case NPCDATAHITWIDTH: SET_NPCDATA_VAR_INT(hxsz, "HitWidth"); break;
22975 case NPCDATAHITHEIGHT: SET_NPCDATA_VAR_INT(hysz, "HitHeight"); break;
22976 case NPCDATAHITZ: SET_NPCDATA_VAR_INT(hzsz, "HitZHeight"); break;
22977 case NPCDATATILEWIDTH: SET_NPCDATA_VAR_INT(txsz, "TileWidth"); break;
22978 case NPCDATATILEHEIGHT: SET_NPCDATA_VAR_INT(tysz, "TileHeight"); break;
22979 case NPCDATAWPNSPRITE: SET_NPCDATA_VAR_INT(wpnsprite, "WeaponSprite"); break;
22980 case NPCDATAWEAPONSCRIPT: SET_NPCDATA_VAR_INT(weaponscript, "WeaponScript"); break;
22981 case NPCDATADEFENSE: SET_NPCDATA_VAR_INDEX(defense, "Defense", 42); break;
22982 case NPCDATAWEAPONINITD: SET_NPCDATA_VAR_INDEX(weap_initiald, "WeaponInitD", 8); break;
22983 case NPCDATAINITD: SET_NPCDATA_VAR_INDEX(initD, "InitD", 8); break;
22984 case NPCDATASIZEFLAG: SET_NPCDATA_VAR_INT(SIZEflags, "SizeFlags"); break;
22985
22986 case NPCDATAFROZENTILE: SET_NPCDATA_VAR_INT(frozentile, "FrozenTile"); break;
22987 case NPCDATAFROZENCSET: SET_NPCDATA_VAR_INT(frozencset, "FrozenCSet"); break;
22988
22989 case NPCDATAATTRIBUTE:
22990 {
22991 int32_t indx = ri->d[rINDEX] / 10000;
22992 if(ri->npcdataref < 0 || ri->npcdataref > (MAXNPCS-1) )
22993 {
22994 Z_scripterrlog("Invalid Sprite ID passed to npcdata->Attributes[]: %d\n", (ri->npcdataref*10000));
22995 }
22996 else if ( indx < 0 || indx > MAX_NPC_ATRIBUTES )
22997 {
22998 Z_scripterrlog("Invalid Array Index passed to npcdata->Attributes[]: %d\n", (ri->npcdataref*10000));
22999 }
23000 else
23001 {
23002 switch(indx)
23003 {
23004 case 0: guysbuf[ri->npcdataref].misc1 = (value / 10000); break;
23005 case 1: guysbuf[ri->npcdataref].misc2 = (value / 10000); break;
23006 case 2: guysbuf[ri->npcdataref].misc3 = (value / 10000); break;
23007 case 3: guysbuf[ri->npcdataref].misc4 = (value / 10000); break;
23008 case 4: guysbuf[ri->npcdataref].misc5 = (value / 10000); break;
23009 case 5: guysbuf[ri->npcdataref].misc6 = (value / 10000); break;
23010 case 6: guysbuf[ri->npcdataref].misc7 = (value / 10000); break;
23011 case 7: guysbuf[ri->npcdataref].misc8 = (value / 10000); break;
23012 case 8: guysbuf[ri->npcdataref].misc9 = (value / 10000); break;
23013 case 9: guysbuf[ri->npcdataref].misc10 = (value / 10000); break;
23014 case 10: guysbuf[ri->npcdataref].misc11 = (value / 10000); break;
23015 case 11: guysbuf[ri->npcdataref].misc12 = (value / 10000); break;
23016 case 12: guysbuf[ri->npcdataref].misc13 = (value / 10000); break;
23017 case 13: guysbuf[ri->npcdataref].misc14 = (value / 10000); break;
23018 case 14: guysbuf[ri->npcdataref].misc15 = (value / 10000); break;
23019
23020 case 15: guysbuf[ri->npcdataref].misc16 = value / 10000; break;
23021 case 16: guysbuf[ri->npcdataref].misc17 = value / 10000; break;
23022 case 17: guysbuf[ri->npcdataref].misc18 = value / 10000; break;
23023 case 18: guysbuf[ri->npcdataref].misc19 = value / 10000; break;
23024 case 19: guysbuf[ri->npcdataref].misc20 = value / 10000; break;
23025 case 20: guysbuf[ri->npcdataref].misc21 = value / 10000; break;
23026 case 21: guysbuf[ri->npcdataref].misc22 = value / 10000; break;
23027 case 22: guysbuf[ri->npcdataref].misc23 = value / 10000; break;
23028 case 23: guysbuf[ri->npcdataref].misc24 = value / 10000; break;
23029 case 24: guysbuf[ri->npcdataref].misc25 = value / 10000; break;
23030 case 25: guysbuf[ri->npcdataref].misc26 = value / 10000; break;
23031 case 26: guysbuf[ri->npcdataref].misc27 = value / 10000; break;
23032 case 27: guysbuf[ri->npcdataref].misc28 = value / 10000; break;
23033 case 28: guysbuf[ri->npcdataref].misc29 = value / 10000; break;
23034 case 29: guysbuf[ri->npcdataref].misc30 = value / 10000; break;
23035 case 30: guysbuf[ri->npcdataref].misc31 = value / 10000; break;
23036 case 31: guysbuf[ri->npcdataref].misc32 = value / 10000; break;
23037
23038 default:
23039 {
23040 Z_scripterrlog("Invalid Array Index passed to npcdata->Attributes[]: %d\n", (ri->npcdataref*10000));
23041 break;
23042 }
23043 }
23044
23045 }
23046 break;
23047 }
23048
23049 case NPCDATABEHAVIOUR:
23050 {
23051 if(ri->npcdataref < 0 || ri->npcdataref > (MAXNPCS-1) )
23052 {
23053 break;
23054 }
23055
23056
23057 int32_t index = vbound(ri->d[rINDEX]/10000,0,4);
23058 switch(index){
23059 case 0:
23060 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG1 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG1;
23061 break;
23062 case 1:
23063 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG2 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG2;
23064 break;
23065 case 2:
23066 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG3 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG3;
23067 break;
23068 case 3:
23069 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG4 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG4;
23070 break;
23071 case 4:
23072 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG5 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG5;
23073 break;
23074 case 5:
23075 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG6 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG6;
23076 break;
23077 case 6:
23078 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG7 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG7;
23079 break;
23080 case 7:
23081 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG8 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG8;
23082 break;
23083 case 8:
23084 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG9 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG9;
23085 break;
23086 case 9:
23087 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG10 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG10;
23088 break;
23089 case 10:
23090 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG11 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG11;
23091 break;
23092 case 11:
23093 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG12 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG12;
23094 break;
23095 case 12:
23096 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG13 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG13;
23097 break;
23098 case 13:
23099 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG14 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG14;
23100 break;
23101 case 14:
23102 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG15 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG15;
23103 break;
23104 case 15:
23105 (value) ? guysbuf[ri->npcdataref].editorflags|=ENEMY_FLAG16 : guysbuf[ri->npcdataref].editorflags&= ~ENEMY_FLAG16;
23106 break;
23107
23108
23109 default:
23110 break;
23111 }
23112
23113 break;
23114 }
23115
23116 case NPCDATASHIELD:
23117 {
23118 int32_t indx = ri->d[rINDEX] / 10000;
23119 if(ri->npcdataref < 0 || ri->npcdataref > (MAXNPCS-1) )
23120 {
23121 Z_scripterrlog("Invalid NPC ID passed to npcdata->Shield[]: %d\n", (ri->npcdataref*10000));
23122 break;
23123 }
23124 else
23125 {
23126 switch(indx)
23127 {
23128 case 0:
23129 {
23130 (ri->d[rINDEX2])? (guysbuf[ri->npcdataref].flags |= inv_front) : (guysbuf[ri->npcdataref].flags &= ~inv_front);
23131 break;
23132 }
23133 case 1:
23134 {
23135 (ri->d[rINDEX2])? (guysbuf[ri->npcdataref].flags |= inv_left) : (guysbuf[ri->npcdataref].flags &= ~inv_left);
23136 break;
23137 }
23138 case 2:
23139 {
23140 (ri->d[rINDEX2])? (guysbuf[ri->npcdataref].flags |= inv_right) : (guysbuf[ri->npcdataref].flags &= ~inv_right);
23141 break;
23142 }
23143 case 3:
23144 {
23145 (ri->d[rINDEX2])? (guysbuf[ri->npcdataref].flags |= inv_back) : (guysbuf[ri->npcdataref].flags &= ~inv_back);
23146 break;
23147 }
23148 case 4:
23149 {
23150 (ri->d[rINDEX2])? (guysbuf[ri->npcdataref].flags |= guy_bkshield) : (guysbuf[ri->npcdataref].flags &= ~guy_bkshield);
23151 break;
23152 }
23153 default:
23154 {
23155 Z_scripterrlog("Invalid Array Index passed to npcdata->Shield[]: %d\n", indx);
23156 break;
23157 }
23158 }
23159 break;
23160 }
23161 }
23162
23163 case NPCDSHADOWSPR:
23164 {
23165 if(ri->npcdataref < 0 || ri->npcdataref > (MAXNPCS-1) )
23166 {
23167 Z_scripterrlog("Invalid NPC ID passed to npcdata->ShadowSprite: %d\n", (ri->npcdataref*10000));
23168 }
23169 else
23170 {
23171 guysbuf[ri->npcdataref].spr_shadow = vbound(value/10000, 0, 255);
23172 }
23173 break;
23174 }
23175 case NPCDSPAWNSPR:
23176 {
23177 if(ri->npcdataref < 0 || ri->npcdataref > (MAXNPCS-1) )
23178 {
23179 Z_scripterrlog("Invalid NPC ID passed to npcdata->SpawnSprite: %d\n", (ri->npcdataref*10000));
23180 }
23181 else
23182 {
23183 guysbuf[ri->npcdataref].spr_spawn = vbound(value/10000, 0, 255);
23184 }
23185 break;
23186 }
23187 case NPCDDEATHSPR:
23188 {
23189 if(ri->npcdataref < 0 || ri->npcdataref > (MAXNPCS-1) )
23190 {
23191 Z_scripterrlog("Invalid NPC ID passed to npcdata->DeathSprite: %d\n", (ri->npcdataref*10000));
23192 }
23193 else
23194 {
23195 guysbuf[ri->npcdataref].spr_death = vbound(value/10000, 0, 255);
23196 }
23197 break;
23198 }
23199
23200
23201 ///----------------------------------------------------------------------------------------------------//
23202 //Dropset Variables
23203
23204 case DROPSETITEMS:
23205 {
23206 if(ri->dropsetref < 0 || ri->dropsetref > MAXITEMDROPSETS)
23207 {
23208 Z_scripterrlog("Invalid dropset pointer %d\n", ri->dropsetref);
23209 break;
23210 }
23211 int32_t indx = ri->d[rINDEX]/10000;
23212 if(indx < 0 || indx > 9)
23213 {
23214 Z_scripterrlog("Invalid index passed to dropdata->Items[]: %d\n", indx);
23215 }
23216 else
23217 {
23218 item_drop_sets[ri->dropsetref].item[indx] = vbound(value / 10000, 0, MAXITEMS-1);
23219 }
23220 break;
23221 }
23222 case DROPSETCHANCES:
23223 {
23224 if(ri->dropsetref < 0 || ri->dropsetref > MAXITEMDROPSETS)
23225 {
23226 Z_scripterrlog("Invalid dropset pointer %d\n", ri->dropsetref);
23227 break;
23228 }
23229 int32_t indx = ri->d[rINDEX]/10000;
23230 if(indx < 0 || indx > 9)
23231 {
23232 Z_scripterrlog("Invalid index passed to dropdata->Chances[]: %d\n", indx);
23233 }
23234 else
23235 {
23236 item_drop_sets[ri->dropsetref].chance[indx+1] = vbound((value / 10000),0,32767); //+1 is because '0' is 'nothing''s chance
23237 }
23238 break;
23239 }
23240 case DROPSETNULLCHANCE:
23241 {
23242 if(ri->dropsetref < 0 || ri->dropsetref > MAXITEMDROPSETS)
23243 {
23244 Z_scripterrlog("Invalid dropset pointer %d\n", ri->dropsetref);
23245 break;
23246 }
23247 item_drop_sets[ri->dropsetref].chance[0] = vbound((value / 10000),0,32767);
23248 break;
23249 }
23250
23251 ///----------------------------------------------------------------------------------------------------//
23252 //Audio Variables
23253
23254 case AUDIOVOLUME:
23255 {
23256 if (!get_qr(qr_OLD_SCRIPT_VOLUME))
23257 break;
23258
23259 int32_t indx = ri->d[rINDEX] / 10000;
23260 //zprint("Volume[index] is: %d", indx);
23261 //int32_t vol = value / 10000;
23262 //zprint("Attempted to change volume to: %d", vol);
23263 switch(indx)
23264 {
23265
23266 case 0: //midi volume
23267 {
23268 if ( !(FFCore.coreflags&FFCORE_SCRIPTED_MIDI_VOLUME) )
23269 {
23270 FFCore.usr_midi_volume = FFScript::do_getMIDI_volume();
23271 FFCore.SetFFEngineFlag(FFCORE_SCRIPTED_MIDI_VOLUME,true);
23272 }
23273 FFScript::do_setMIDI_volume(value / 10000);
23274 break;
23275 }
23276 case 1: //digi volume
23277 {
23278 if ( !(FFCore.coreflags&FFCORE_SCRIPTED_DIGI_VOLUME) )
23279 {
23280 FFCore.usr_digi_volume = FFScript::do_getDIGI_volume();
23281 FFCore.SetFFEngineFlag(FFCORE_SCRIPTED_DIGI_VOLUME,true);
23282 }
23283 FFScript::do_setDIGI_volume(value / 10000);
23284 break;
23285 }
23286 case 2: //emh music volume
23287 {
23288 if ( !(FFCore.coreflags&FFCORE_SCRIPTED_MUSIC_VOLUME) )
23289 {
23290 FFCore.usr_music_volume = FFScript::do_getMusic_volume();
23291 FFCore.SetFFEngineFlag(FFCORE_SCRIPTED_MUSIC_VOLUME,true);
23292 }
23293 FFScript::do_setMusic_volume(value / 10000);
23294 break;
23295 }
23296 case 3: //sfx volume
23297 {
23298 if ( !(FFCore.coreflags&FFCORE_SCRIPTED_SFX_VOLUME) )
23299 {
23300 FFCore.usr_sfx_volume = FFScript::do_getSFX_volume();
23301 FFCore.SetFFEngineFlag(FFCORE_SCRIPTED_SFX_VOLUME,true);
23302 }
23303 FFScript::do_setSFX_volume(value / 10000);
23304 break;
23305 }
23306 default:
23307 {
23308 Z_scripterrlog("Attempted to access an invalid index of Audio->Volume[]", indx);
23309 break;
23310 }
23311 }
23312 break;
23313 }
23314
23315 case AUDIOPAN:
23316 {
23317 if ( !(FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE) )
23318 {
23319 FFCore.usr_panstyle = FFScript::do_getSFX_pan();
23320 FFCore.SetFFEngineFlag(FFCORE_SCRIPTED_PANSTYLE,true);
23321 }
23322 FFScript::do_setSFX_pan(value/10000);
23323 break;
23324 }
23325
23326 ///----------------------------------------------------------------------------------------------------//
23327 //Graphics->
23328
23329 case NUMDRAWS:
23330 break;
23331
23332 case MAXDRAWS: break;
23333
23334 ///----------------------------------------------------------------------------------------------------//
23335 //Module->
23336 case MODULEGETSTR:
23337 {
23338 int32_t buf_pointer = ((ri->d[rINDEX])/10000);
23339 int32_t section_pointer = ((ri->d[rINDEX2])/10000);
23340 int32_t element_pointer = (value/10000);
23341
23342 string sectionid;
23343 string elementid;
23344
23345 ArrayH::getString(section_pointer, sectionid);
23346 ArrayH::getString(element_pointer, elementid);
23347
23348 char buffer[256] = {0};
23349
23350
23351 if(!fileexists((char*)moduledata.module_name))
23352 {
23353 Z_scripterrlog("I/O Error: No module definitions found when using Module->GetString()\n");
23354 }
23355 else
23356 {
23357 zc_push_config();
23358 //set config file
23359 zc_config_file(moduledata.module_name);
23360 strcpy(buffer,zc_get_config_basic(sectionid.c_str(), elementid.c_str(), ""));
23361 buffer[255] = '\0';
23362 if(ArrayH::setArray(buf_pointer, buffer) == SH::_Overflow)
23363 Z_scripterrlog("Dest string supplied to 'Module->GetString()' is not large enough\n");
23364 //return config file to zc.cfg
23365 zc_pop_config();
23366 }
23367
23368 break;
23369 }
23370
23371 ///----------------------------------------------------------------------------------------------------//
23372 //Misc./Internal
23373 case SP:
23374 ri->sp = value / 10000;
23375 ri->sp &= MASK_SP;
23376 break;
23377
23378 case PC:
23379 ri->pc = value;
23380 break;
23381
23382 case SWITCHKEY:
23383 ri->switchkey = value;
23384 break;
23385
23386 case SCRIPTRAM:
23387 case GLOBALRAM:
23388 455505918 ArrayH::setElement(ri->d[rINDEX] / 10000, ri->d[rINDEX2] / 10000, value);
23389 455505918 break;
23390
23391 case SCRIPTRAMD:
23392 case GLOBALRAMD:
23393 ArrayH::setElement(ri->d[rINDEX] / 10000, 0, value);
23394 break;
23395
23396 case REFFFC:
23397 503793134 ri->ffcref = value / 10000;
23398 503793134 break;
23399
23400 case REFITEM:
23401 409929 ri->itemref = value;
23402 409929 break;
23403
23404 case REFITEMCLASS:
23405 375716 ri->idata = value;
23406 375716 break;
23407
23408 case REFLWPN:
23409 10112990 ri->lwpn = value;
23410 10112990 break;
23411
23412 case REFEWPN:
23413 23554631 ri->ewpn = value;
23414 23554631 break;
23415
23416 case REFNPC:
23417 78110851 ri->guyref = value;
23418 78110851 break;
23419
23420 18513311 case REFMAPDATA: ri->mapsref = value; break;
23421 case REFSCREENDATA: ri->screenref = value; break;
23422 116558 case REFCOMBODATA: ri->combosref = value; break;
23423 case REFSPRITEDATA: ri->spritesref = value; break;
23424 257126 case REFBITMAP: ri->bitmapref = value; break;
23425 case REFNPCCLASS: ri->npcdataref = value; break;
23426
23427 758256 case REFDMAPDATA: ri->dmapsref = value; break;
23428 case REFSHOPDATA: ri->shopsref = value; break;
23429 case REFMSGDATA: ri->zmsgref = value; break;
23430 case REFUNTYPED: ri->untypedref = value; break;
23431
23432
23433 case REFDROPS: ri->dropsetref = value; break;
23434 case REFBOTTLETYPE: ri->bottletyperef = value; break;
23435 case REFBOTTLESHOP: ri->bottleshopref = value; break;
23436 142 case REFGENERICDATA: ri->genericdataref = value; break;
23437 case REFPONDS: ri->pondref = value; break;
23438 case REFWARPRINGS: ri->warpringref = value; break;
23439 case REFDOORS: ri->doorsref = value; break;
23440 case REFUICOLOURS: ri->zcoloursref = value; break;
23441 case REFRGB: ri->rgbref = value; break;
23442 case REFPALETTE: ri->paletteref = value; break;
23443 case REFTUNES: ri->tunesref = value; break;
23444 case REFPALCYCLE: ri->palcycleref = value; break;
23445 case REFGAMEDATA: ri->gamedataref = value; break;
23446 case REFCHEATS: ri->cheatsref = value; break;
23447 284 case REFFILE: ri->fileref = value; break;
23448 case REFDIRECTORY: ri->directoryref = value; break;
23449 case REFSTACK: ri->stackref = value; break;
23450 case REFSUBSCREEN: ri->subscreenref = value; break;
23451 303330 case REFRNG: ri->rngref = value; break;
23452 case CLASS_THISKEY: ri->thiskey = value; break;
23453 case CLASS_THISKEY2: ri->thiskey2 = value; break;
23454 case REFPALDATA: ri->paldataref = value; break;
23455
23456 //-------------------------------------------------------------------------------------------------
23457
23458 case PALDATACOLOR:
23459 {
23460 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->SetColor()"))
23461 {
23462 int32_t ind = ri->d[rINDEX] / 10000;
23463 if (unsigned(ind) >= PALDATA_NUM_COLORS)
23464 {
23465 Z_scripterrlog("Invalid color index (%d) passed to paldata->SetColor(). Valid indices are 0-255. Aborting.\n", ind);
23466 break;
23467 }
23468 int32_t clri = value;
23469
23470 RGB c = _RGB((clri >> 16) & 0xFF, (clri >> 8) & 0xFF, clri & 0xFF);
23471
23472 if (c.r < 0 || c.g < 0 || c.b < 0)
23473 {
23474 Z_scripterrlog("Invalid rgb (%d) passed to paldata->SetColor().\n", clri);
23475 }
23476 c.r = vbound(c.r, 0, 63);
23477 c.g = vbound(c.g, 0, 63);
23478 c.b = vbound(c.b, 0, 63);
23479
23480 pd->set_color(ind, c);
23481 }
23482 break;
23483 }
23484 case PALDATAR:
23485 FFCore.do_paldata_setrgb(0, value / 10000);
23486 break;
23487 case PALDATAG:
23488 FFCore.do_paldata_setrgb(1, value / 10000);
23489 break;
23490 case PALDATAB:
23491 FFCore.do_paldata_setrgb(2, value / 10000);
23492 break;
23493
23494 //-------------------------------------------------------------------------------------------------
23495
23496 case GENDATARUNNING:
23497 {
23498
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "Running"))
23499 {
23500
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(value)
23501 58 scr->launch();
23502 else scr->quit();
23503 58 }
23504 58 break;
23505 }
23506 case GENDATASIZE:
23507 {
23508 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "DataSize"))
23509 {
23510 scr->dataResize(value/10000);
23511 }
23512 break;
23513 }
23514 case GENDATAEXITSTATE:
23515 {
23516 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "ExitState"))
23517 {
23518 size_t indx = ri->d[rINDEX]/10000;
23519 if(indx >= GENSCR_NUMST)
23520 {
23521 Z_scripterrlog("Invalid index passed to genericdata->ReloadState[]: %d\n", indx);
23522 break;
23523 }
23524 SETFLAG(scr->exitState, (1<<indx), value);
23525 }
23526 break;
23527 }
23528 case GENDATARELOADSTATE:
23529 {
23530
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "ReloadState"))
23531 {
23532 74 size_t indx = ri->d[rINDEX]/10000;
23533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(indx >= GENSCR_NUMST)
23534 {
23535 Z_scripterrlog("Invalid index passed to genericdata->ReloadState[]: %d\n", indx);
23536 break;
23537 }
23538
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 SETFLAG(scr->reloadState, (1<<indx), value);
23539 74 }
23540 74 break;
23541 }
23542 case GENDATAEVENTSTATE:
23543 {
23544 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "EventListen"))
23545 {
23546 size_t indx = ri->d[rINDEX]/10000;
23547 if(indx >= GENSCR_NUMEVENT)
23548 {
23549 Z_scripterrlog("Invalid index passed to genericdata->EventListen[]: %d\n", indx);
23550 break;
23551 }
23552 SETFLAG(scr->eventstate, (1<<indx), value);
23553 }
23554 break;
23555 }
23556 case GENDATADATA:
23557 {
23558 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "Data[]"))
23559 {
23560 size_t indx = ri->d[rINDEX]/10000;
23561 if(indx >= scr->dataSize())
23562 {
23563 Z_scripterrlog("Invalid index passed to genericdata->Data[]: %d\n", indx);
23564 break;
23565 }
23566 scr->data[indx] = value;
23567 }
23568 break;
23569 }
23570 case GENDATAINITD:
23571 {
23572 if(user_genscript* scr = checkGenericScr(ri->genericdataref, "InitD[]"))
23573 {
23574 size_t indx = ri->d[rINDEX]/10000;
23575 if(indx >= 8)
23576 {
23577 Z_scripterrlog("Invalid index passed to genericdata->InitD[]: %d\n", indx);
23578 break;
23579 }
23580 scr->initd[indx] = value;
23581 }
23582 break;
23583 }
23584
23585 //----------------------------------------------------------------------------------------------------//
23586
23587 case PORTALX:
23588 {
23589 if(portal* p = checkPortal(ri->portalref, "X"))
23590 p->x = zslongToFix(value);
23591 break;
23592 }
23593 case PORTALY:
23594 {
23595 if(portal* p = checkPortal(ri->portalref, "Y"))
23596 p->y = zslongToFix(value);
23597 break;
23598 }
23599 case PORTALDMAP:
23600 {
23601 if(portal* p = checkPortal(ri->portalref, "DMap"))
23602 p->destdmap = vbound(value/10000,-1,MAXDMAPS-1);
23603 break;
23604 }
23605 case PORTALSCREEN:
23606 {
23607 if(portal* p = checkPortal(ri->portalref, "Screen"))
23608 p->destscr = vbound(value/10000,0,255);
23609 break;
23610 }
23611 case PORTALACLK:
23612 {
23613 if(portal* p = checkPortal(ri->portalref, "AClk"))
23614 p->aclk = vbound(value/10000, 0, 9999);
23615 break;
23616 }
23617 case PORTALAFRM:
23618 {
23619 if(portal* p = checkPortal(ri->portalref, "AFrame"))
23620 p->aframe = vbound(value/10000, 0, 9999);
23621 break;
23622 }
23623 case PORTALOTILE:
23624 {
23625 if(portal* p = checkPortal(ri->portalref, "OriginalTile"))
23626 p->o_tile = vbound(value/10000, 0, NEWMAXTILES-1);
23627 break;
23628 }
23629 case PORTALASPD:
23630 {
23631 if(portal* p = checkPortal(ri->portalref, "ASpeed"))
23632 p->aspd = vbound(value/10000, 0, 9999);
23633 break;
23634 }
23635 case PORTALFRAMES:
23636 {
23637 if(portal* p = checkPortal(ri->portalref, "Frames"))
23638 p->frames = vbound(value/10000, 0, 9999);
23639 break;
23640 }
23641 case PORTALSAVED:
23642 {
23643 if(ri->portalref < 0 || value < 0) break;
23644 if(portal* p = checkPortal(ri->portalref, "SavedPortal"))
23645 {
23646 if(!value)
23647 p->saved_data = 0;
23648 else if(savedportal* sp = checkSavedPortal(value, "portal->SavedPortal"))
23649 p->saved_data = sp->getUID();
23650 }
23651 break;
23652 }
23653 case PORTALCLOSEDIS:
23654 {
23655 if(portal* p = checkPortal(ri->portalref, "CloseDisabled"))
23656 p->prox_active = value==0; //Inverted
23657 break;
23658 }
23659 case REFPORTAL:
23660 {
23661 ri->portalref = value;
23662 break;
23663 }
23664 case REFSAVPORTAL:
23665 {
23666 ri->saveportalref = value;
23667 break;
23668 }
23669 case PORTALWARPSFX:
23670 {
23671 if(portal* p = checkPortal(ri->portalref, "WarpSFX"))
23672 p->wsfx = vbound(value/10000,0,255);
23673 break;
23674 }
23675 case PORTALWARPVFX:
23676 {
23677 if(portal* p = checkPortal(ri->portalref, "WarpEffect"))
23678 p->weffect = vbound(value/10000,0,255);
23679 break;
23680 }
23681 case SAVEDPORTALX:
23682 {
23683 if(savedportal* p = checkSavedPortal(ri->saveportalref, "X"))
23684 p->x = value;
23685 break;
23686 }
23687 case SAVEDPORTALY:
23688 {
23689 if(savedportal* p = checkSavedPortal(ri->saveportalref, "Y"))
23690 p->y = value;
23691 break;
23692 }
23693 case SAVEDPORTALSRCDMAP:
23694 {
23695 if(savedportal* p = checkSavedPortal(ri->saveportalref, "SrcDMap"))
23696 p->srcdmap = vbound(value/10000, -1, MAXDMAPS-1);
23697 break;
23698 }
23699 case SAVEDPORTALDESTDMAP:
23700 {
23701 if(savedportal* p = checkSavedPortal(ri->saveportalref, "DestDMap"))
23702 p->destdmap = vbound(value/10000, -1, MAXDMAPS-1);
23703 break;
23704 }
23705 case SAVEDPORTALSRCSCREEN:
23706 {
23707 if(savedportal* p = checkSavedPortal(ri->saveportalref, "SrcScreen"))
23708 p->srcscr = vbound(value/10000,0,255);
23709 break;
23710 }
23711 case SAVEDPORTALDSTSCREEN:
23712 {
23713 if(savedportal* p = checkSavedPortal(ri->saveportalref, "DestScreen"))
23714 p->destscr = vbound(value/10000,0,255);
23715 break;
23716 }
23717 case SAVEDPORTALWARPSFX:
23718 {
23719 if(savedportal* p = checkSavedPortal(ri->saveportalref, "WarpSFX"))
23720 p->sfx = vbound(value/10000,0,255);
23721 break;
23722 }
23723 case SAVEDPORTALWARPVFX:
23724 {
23725 if(savedportal* p = checkSavedPortal(ri->saveportalref, "WarpEffect"))
23726 p->warpfx = vbound(value/10000,0,255);
23727 break;
23728 }
23729 case SAVEDPORTALSPRITE:
23730 {
23731 if(savedportal* p = checkSavedPortal(ri->saveportalref, "Sprite"))
23732 p->spr = vbound(value/10000,0,255);
23733 break;
23734 }
23735 case SAVEDPORTALPORTAL:
23736 {
23737 if(ri->saveportalref < 0 || value < 0) break;
23738 if(savedportal* sp = checkSavedPortal(ri->saveportalref, "Portal"))
23739 {
23740 int32_t id = getPortalFromSaved(sp);
23741 if(id == value) break; //no change
23742 portal* p = checkPortal(value,"savedportal->Portal");
23743 if(p)
23744 {
23745 p->saved_data = sp->getUID();
23746 if(id > 0)
23747 {
23748 portal* p = checkPortal(id,"THIS SHOULD NOT APPEAR");
23749 p->saved_data = 0;
23750 }
23751 }
23752 }
23753 break;
23754 }
23755
23756 default:
23757 {
23758
2/4
✓ Branch 0 taken 261416152 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 261416152 times.
261416152 if(arg >= D(0) && arg <= D(7)) ri->d[arg - D(0)] = value;
23759 else if(arg >= A(0) && arg <= A(1)) ri->a[arg - A(0)] = value;
23760 else if(arg >= GD(0) && arg <= GD(MAX_SCRIPT_REGISTERS)) game->global_d[arg-GD(0)] = value;
23761
23762 261416152 break;
23763 }
23764 }
23765 1398816592 } //end set_register
23766
23767 int32_t get_int_arr(const int32_t ptr, int32_t indx)
23768 {
23769 switch(ptr)
23770 {
23771 case INTARR_SCREEN_NPC:
23772 {
23773 if(BC::checkGuyIndex(indx, "Screen->NPCs[]") != SH::_NoError)
23774 return 0;
23775 return guys.spr(indx)->getUID();
23776 }
23777 case INTARR_SCREEN_ITEMSPR:
23778 {
23779 if(BC::checkItemIndex(indx, "Screen->Items[]") != SH::_NoError)
23780 return 0;
23781 return items.spr(indx)->getUID();
23782 }
23783 case INTARR_SCREEN_LWPN:
23784 {
23785 if(BC::checkLWeaponIndex(indx, "Screen->LWeapons[]") != SH::_NoError)
23786 return 0;
23787 return Lwpns.spr(indx)->getUID();
23788 }
23789 case INTARR_SCREEN_EWPN:
23790 {
23791 if(BC::checkEWeaponIndex(indx, "Screen->EWeapons[]") != SH::_NoError)
23792 return 0;
23793 return Ewpns.spr(indx)->getUID();
23794 }
23795 case INTARR_SCREEN_FFC:
23796 {
23797 if(BC::checkFFC(indx, "Screen->FFCs[]") != SH::_NoError)
23798 return 0;
23799 return indx*10000;
23800 }
23801 case INTARR_SCREEN_PORTALS:
23802 {
23803 if(BC::checkBoundsOneIndexed(indx, 0, portals.Count()-1, "Screen->Portals[]") != SH::_NoError)
23804 return 0;
23805 return portals.spr(indx)->getUID();
23806 }
23807 case INTARR_SAVPRTL:
23808 {
23809 if(BC::checkBoundsOneIndexed(indx, 0, game->user_portals.size()-1, "Game->SavedPortals[]") != SH::_NoError)
23810 return 0;
23811 return (indx+1)*10000;
23812 }
23813 default:
23814 {
23815 Z_scripterrlog("Unknown internal array '%d' read from!\n", ptr);
23816 return 0;
23817 }
23818 }
23819 }
23820 void set_int_arr(const int32_t ptr, int32_t indx, int32_t val)
23821 {
23822 switch(ptr)
23823 {
23824 case INTARR_SCREEN_NPC:
23825 Z_scripterrlog("Read-only array 'Screen->NPCs' cannot be written to!\n");
23826 return;
23827 case INTARR_SCREEN_ITEMSPR:
23828 Z_scripterrlog("Read-only array 'Screen->Items' cannot be written to!\n");
23829 return;
23830 case INTARR_SCREEN_LWPN:
23831 Z_scripterrlog("Read-only array 'Screen->LWeapons' cannot be written to!\n");
23832 return;
23833 case INTARR_SCREEN_EWPN:
23834 Z_scripterrlog("Read-only array 'Screen->EWeapons' cannot be written to!\n");
23835 return;
23836 case INTARR_SCREEN_FFC:
23837 Z_scripterrlog("Read-only array 'Screen->FFCs' cannot be written to!\n");
23838 return;
23839 case INTARR_SCREEN_PORTALS:
23840 Z_scripterrlog("Read-only array 'Screen->Portals' cannot be written to!\n");
23841 return;
23842 case INTARR_SAVPRTL:
23843 Z_scripterrlog("Read-only array 'Game->SavedPortals' cannot be written to!\n");
23844 return;
23845
23846 default:
23847 {
23848 Z_scripterrlog("Unknown internal array '%d' written to!\n", ptr);
23849 return;
23850 }
23851 }
23852 }
23853 int32_t sz_int_arr(const int32_t ptr)
23854 {
23855 switch(ptr)
23856 {
23857 case INTARR_SCREEN_NPC:
23858 {
23859 return guys.Count();
23860 }
23861 case INTARR_SCREEN_ITEMSPR:
23862 {
23863 return items.Count();
23864 }
23865 case INTARR_SCREEN_LWPN:
23866 {
23867 return Lwpns.Count();
23868 }
23869 case INTARR_SCREEN_EWPN:
23870 {
23871 return Ewpns.Count();
23872 }
23873 case INTARR_SCREEN_FFC:
23874 {
23875 return MAXFFCS;
23876 }
23877 case INTARR_SCREEN_PORTALS:
23878 {
23879 return portals.Count();
23880 }
23881 case INTARR_SAVPRTL:
23882 {
23883 return game->user_portals.size();
23884 }
23885 default:
23886 {
23887 Z_scripterrlog("Unknown internal array '%d' size read!\n", ptr);
23888 return -1;
23889 }
23890 }
23891 }
23892
23893 ///----------------------------------------------------------------------------------------------------//
23894 // ASM Functions //
23895 ///----------------------------------------------------------------------------------------------------//
23896
23897
23898 ///----------------------------------------------------------------------------------------------------//
23899 //Internal (to ZScript)
23900
23901 void do_set(const bool v, ScriptType whichType, const int32_t whichUID)
23902 {
23903 bool allowed = true;
23904 switch(whichType) //Check for objects attempting to change own script
23905 {
23906 //case ScriptType::Global:
23907
23908 case ScriptType::FFC:
23909 if(sarg1==FFSCRIPT && ri->ffcref==whichUID)
23910 allowed = false;
23911 break;
23912
23913 case ScriptType::Screen:
23914 if(sarg1==SCREENSCRIPT) //Only 1 screen script running at a time, no UID check needed
23915 allowed = false;
23916 break;
23917
23918 //case ScriptType::Player:
23919
23920 case ScriptType::Item:
23921 {
23922 bool collect = ( ( whichUID < 1 ) || (whichUID == COLLECT_SCRIPT_ITEM_ZERO) );
23923 int32_t new_UID = ( collect ) ? (( whichUID != COLLECT_SCRIPT_ITEM_ZERO ) ? (whichUID * -1) : 0) : whichUID;
23924
23925 if(collect)
23926 {
23927 if(sarg1==IDATAPSCRIPT && ri->idata==new_UID)
23928 allowed = false;
23929 }
23930 else if(sarg1==IDATASCRIPT && ri->idata==new_UID)
23931 allowed = false;
23932 break;
23933 }
23934
23935 case ScriptType::Lwpn:
23936 if(sarg1==LWPNSCRIPT && ri->lwpn==whichUID)
23937 allowed = false;
23938 break;
23939
23940 case ScriptType::NPC:
23941 if(sarg1==NPCSCRIPT && ri->guyref==whichUID)
23942 allowed = false;
23943 break;
23944
23945 //case ScriptType::Subscreen:
23946
23947 case ScriptType::Ewpn:
23948 if(sarg1==EWPNSCRIPT && ri->ewpn==whichUID)
23949 allowed = false;
23950 break;
23951
23952 case ScriptType::DMap:
23953 if(sarg1==DMAPSCRIPT && ri->dmapsref==whichUID)
23954 allowed = false;
23955 break;
23956
23957 case ScriptType::ItemSprite:
23958 if(sarg1==ITEMSPRITESCRIPT && ri->itemref==whichUID)
23959 allowed = false;
23960 break;
23961 }
23962 if(!allowed)
23963 {
23964 Z_scripterrlog("Script attempted to change own object's script! This has been ignored.\n");
23965 return;
23966 }
23967 int32_t temp = SH::get_arg(sarg2, v);
23968 set_register(sarg1, temp);
23969 }
23970
23971 void do_push(const bool v)
23972 {
23973 const int32_t value = SH::get_arg(sarg1, v);
23974 --ri->sp;
23975 ri->sp &= MASK_SP;
23976 SH::write_stack(ri->sp, value);
23977 }
23978 57459 void do_push_varg(const bool v)
23979 {
23980 57459 const int32_t value = SH::get_arg(sarg1, v);
23981 57459 zs_vargs.push_back(value);
23982 57459 }
23983
23984 void do_pop()
23985 {
23986 const int32_t value = SH::read_stack(ri->sp);
23987 ++ri->sp;
23988 ri->sp &= MASK_SP;
23989 set_register(sarg1, value);
23990 }
23991
23992 58814 void do_peek()
23993 {
23994 58814 set_register(sarg1, SH::read_stack(ri->sp));
23995 58814 }
23996
23997 void do_pops() // Pop past a bunch of stuff at once. Useful for clearing the stack.
23998 {
23999 int32_t num = sarg2;
24000 ri->sp += num;
24001 ri->sp &= MASK_SP;
24002 word read = (ri->sp-1) & MASK_SP;
24003 int32_t value = SH::read_stack(read);
24004 set_register(sarg1, value);
24005 }
24006
24007 void do_loadi()
24008 {
24009 const int32_t stackoffset = get_register(sarg2) / 10000;
24010 const int32_t value = SH::read_stack(stackoffset);
24011 set_register(sarg1, value);
24012 }
24013
24014 void do_storei()
24015 {
24016 const int32_t stackoffset = get_register(sarg2) / 10000;
24017 const int32_t value = get_register(sarg1);
24018 SH::write_stack(stackoffset, value);
24019 }
24020
24021 void do_loadd()
24022 {
24023 const int32_t stackoffset = (sarg2+ri->d[rSFRAME]) / 10000;
24024 const int32_t value = SH::read_stack(stackoffset);
24025 set_register(sarg1, value);
24026 }
24027
24028 void do_stored()
24029 {
24030 const int32_t stackoffset = (sarg2+ri->d[rSFRAME]) / 10000;
24031 const int32_t value = get_register(sarg1);
24032 SH::write_stack(stackoffset, value);
24033 }
24034
24035 void do_enqueue(const bool)
24036 {
24037 }
24038 void do_dequeue(const bool)
24039 {
24040 }
24041
24042 void do_comp(bool v, const bool inv = false)
24043 {
24044 bool v2 = false;
24045 if(inv) zc_swap(v,v2);
24046 int32_t temp = SH::get_arg(sarg2, v);
24047 int32_t temp2 = SH::get_arg(sarg1, v2);
24048
24049 if(temp2 >= temp) ri->scriptflag |= MOREFLAG;
24050 else ri->scriptflag &= ~MOREFLAG;
24051
24052 if(temp2 == temp) ri->scriptflag |= TRUEFLAG;
24053 else ri->scriptflag &= ~TRUEFLAG;
24054 }
24055
24056 void do_internal_strcmp()
24057 {
24058 int32_t arrayptr_a = get_register(sarg1)/10000;
24059 int32_t arrayptr_b = get_register(sarg2)/10000;
24060 string strA;
24061 string strB;
24062 ArrayH::getString(arrayptr_a, strA);
24063 ArrayH::getString(arrayptr_b, strB);
24064 int32_t temp = strcmp(strA.c_str(), strB.c_str());
24065
24066 if(temp >= 0) ri->scriptflag |= MOREFLAG;
24067 else ri->scriptflag &= ~MOREFLAG;
24068
24069 if(temp == 0) ri->scriptflag |= TRUEFLAG;
24070 else ri->scriptflag &= ~TRUEFLAG;
24071 }
24072
24073 void do_internal_stricmp()
24074 {
24075 int32_t arrayptr_a = get_register(sarg1)/10000;
24076 int32_t arrayptr_b = get_register(sarg2)/10000;
24077 string strA;
24078 string strB;
24079 ArrayH::getString(arrayptr_a, strA);
24080 ArrayH::getString(arrayptr_b, strB);
24081 int32_t temp = stricmp(strA.c_str(), strB.c_str());
24082
24083 if(temp >= 0) ri->scriptflag |= MOREFLAG;
24084 else ri->scriptflag &= ~MOREFLAG;
24085
24086 if(temp == 0) ri->scriptflag |= TRUEFLAG;
24087 else ri->scriptflag &= ~TRUEFLAG;
24088 }
24089
24090 void do_resize_array()
24091 {
24092 int32_t size = vbound(get_register(sarg2) / 10000, 1, 214748);
24093 dword ptrval = get_register(sarg1) / 10000;
24094 ArrayManager am(ptrval);
24095 am.resize(size);
24096 }
24097
24098 void do_own_array(dword arrindx, ScriptType scriptType, const int32_t UID)
24099 {
24100 ArrayManager am(arrindx);
24101
24102 if(am.internal())
24103 {
24104 Z_scripterrlog("Cannot 'OwnArray()' an internal array '%d'\n", arrindx);
24105 return;
24106 }
24107 if(arrindx >= NUM_ZSCRIPT_ARRAYS && arrindx < NUM_ZSCRIPT_ARRAYS*2)
24108 {
24109 //ignore global arrays
24110 }
24111 else if(!am.invalid())
24112 {
24113 if(arrindx > 0 && arrindx < NUM_ZSCRIPT_ARRAYS)
24114 {
24115 arrayOwner[arrindx].scriptType = scriptType;
24116 arrayOwner[arrindx].ownerUID = UID;
24117 arrayOwner[arrindx].specOwned = true;
24118 arrayOwner[arrindx].specCleared = false;
24119 }
24120 else if(arrindx < 0) //object array
24121 Z_scripterrlog("Cannot 'OwnArray()' an object-based array '%d'\n", arrindx);
24122 }
24123 else Z_scripterrlog("Tried to 'OwnArray()' an invalid array '%d'\n", arrindx);
24124 }
24125 void do_destroy_array()
24126 {
24127 dword arrindx = get_register(sarg1) / 10000;
24128
24129 ArrayManager am(arrindx);
24130
24131 if(am.internal())
24132 {
24133 Z_scripterrlog("Cannot 'DestroyArray()' an internal array '%d'\n", arrindx);
24134 return;
24135 }
24136
24137 if(arrindx >= NUM_ZSCRIPT_ARRAYS && arrindx < NUM_ZSCRIPT_ARRAYS*2)
24138 {
24139 //ignore global arrays
24140 }
24141 else if(!am.invalid())
24142 {
24143 if(arrindx > 0 && arrindx < NUM_ZSCRIPT_ARRAYS)
24144 {
24145 arrayOwner[arrindx].clear();
24146
24147 if(localRAM[arrindx].Size() == 0)
24148 ;
24149 else
24150 {
24151 localRAM[arrindx].Clear();
24152 }
24153 arrayOwner[arrindx].specCleared = true;
24154 }
24155 else if(arrindx < 0) //object array
24156 Z_scripterrlog("Cannot 'DestroyArray()' an object-based array '%d'\n", arrindx);
24157 }
24158 else Z_scripterrlog("Tried to 'DestroyArray()' an invalid array '%d'\n", arrindx);
24159 }
24160
24161 7004663 void do_allocatemem(const bool v, const bool local, ScriptType type, const uint32_t UID)
24162 {
24163 7004663 const int32_t size = SH::get_arg(sarg2, v) / 10000;
24164 dword ptrval;
24165
24166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7004663 times.
7004663 if(size <= 0)
24167 {
24168 Z_scripterrlog("Array initialized to invalid size of %d\n", size);
24169 set_register(sarg1, 0); //Pass back NULL
24170 return;
24171 }
24172
24173
2/2
✓ Branch 0 taken 7004366 times.
✓ Branch 1 taken 297 times.
7004663 if(local)
24174 {
24175 //localRAM[0] is used as an invalid container, so 0 can be the NULL pointer in ZScript
24176
2/2
✓ Branch 0 taken 383446146 times.
✓ Branch 1 taken 7004366 times.
390450512 for(ptrval = 1; localRAM[ptrval].Size() != 0; ptrval++) ;
24177
24178
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7004366 times.
7004366 if(ptrval >= NUM_ZSCRIPT_ARRAYS)
24179 {
24180 Z_scripterrlog("%d local arrays already in use, no more can be allocated\n", NUM_ZSCRIPT_ARRAYS-1);
24181 ptrval = 0;
24182 }
24183 else
24184 {
24185 7004366 ZScriptArray &a = localRAM[ptrval]; //marginally faster for large arrays if we use a reference
24186
24187 7004366 a.Resize(size);
24188
24189
2/2
✓ Branch 0 taken 106851155 times.
✓ Branch 1 taken 7004366 times.
113855521 for(dword j = 0; j < (dword)size; j++)
24190 106851155 a[j] = 0; //initialize array
24191
24192 // Keep track of which object created the array so we know which to deallocate
24193 //Z_eventlog("Allocating array %d to script %s, %d\n", ptrval, script_types[type], UID);
24194 7004366 arrayOwner[ptrval].scriptType = type;
24195 7004366 arrayOwner[ptrval].ownerUID = UID;
24196 7004366 arrayOwner[ptrval].specOwned = false;
24197 7004366 arrayOwner[ptrval].specCleared = false;
24198 }
24199 7004366 }
24200 else
24201 {
24202 //Globals are only allocated here at first play, otherwise in init_game
24203
2/2
✓ Branch 0 taken 5337 times.
✓ Branch 1 taken 297 times.
5634 for(ptrval = 0; game->globalRAM[ptrval].Size() != 0; ptrval++) ;
24204
24205
1/2
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
297 if(ptrval >= game->globalRAM.size())
24206 {
24207 al_trace("Invalid pointer value of %u passed to global allocate\n", ptrval);
24208 //this shouldn't happen, unless people are putting ALLOCATEGMEM in their ZASM scripts where they shouldn't be
24209 }
24210
24211 297 ZScriptArray &a = game->globalRAM[ptrval];
24212
24213 297 a.Resize(size);
24214
24215
2/2
✓ Branch 0 taken 450260 times.
✓ Branch 1 taken 297 times.
450557 for(dword j = 0; j < (dword)size; j++)
24216 450260 a[j] = 0;
24217
24218 297 ptrval += NUM_ZSCRIPT_ARRAYS; //so each pointer has a unique value
24219 }
24220
24221
24222 7004663 set_register(sarg1, ptrval * 10000);
24223
24224 // If this happens once per frame, it can drown out every other message. -L
24225 /*Z_eventlog("Allocated %s array of size %d, pointer address %ld\n",
24226 local ? "local": "global", size, ptrval);*/
24227 7004663 }
24228
24229 6979847 void do_deallocatemem()
24230 {
24231 6979847 const int32_t ptrval = get_register(sarg1) / 10000;
24232
24233 6979847 FFScript::deallocateZScriptArray(ptrval);
24234 6979847 }
24235
24236 void do_loada(const byte a)
24237 {
24238 if(ri->a[a] == 0)
24239 {
24240 Z_eventlog("Global scripts currently have no A registers\n");
24241 return;
24242 }
24243
24244 int32_t ffcref = (ri->a[a] / 10000) - 1; //FFC 2
24245
24246 if(BC::checkFFC(ffcref, "LOAD%i") != SH::_NoError)
24247 return;
24248
24249 int32_t reg = get_register(sarg2); //Register in FFC 2
24250
24251 if(reg >= D(0) && reg <= D(7))
24252 set_register(sarg1, FFCore.ref(ScriptType::FFC, ffcref).d[reg - D(0)]); //get back the info into *sarg1
24253 else if(reg == A(0) || reg == A(1))
24254 set_register(sarg1, FFCore.ref(ScriptType::FFC, ffcref).a[reg - A(0)]);
24255 else if(reg == SP)
24256 set_register(sarg1, FFCore.ref(ScriptType::FFC, ffcref).sp * 10000);
24257
24258 //Can get everything else using REFFFC
24259 }
24260
24261 void do_seta(const byte a)
24262 {
24263 if(ri->a[a] == 0)
24264 {
24265 Z_eventlog("Global scripts currently have no A registers\n");
24266 return;
24267 }
24268
24269 int32_t ffcref = (ri->a[a] / 10000) - 1; //FFC 2
24270
24271 if(BC::checkFFC(ffcref, "SETA%i") != SH::_NoError)
24272 return;
24273
24274 int32_t reg = get_register(sarg2); //Register in FFC 2
24275
24276 if(reg >= D(0) && reg <= D(7))
24277 FFCore.ref(ScriptType::FFC, ffcref).d[reg - D(0)] = get_register(sarg1); //Set it to *sarg1
24278 else if(reg == A(0) || reg == A(1))
24279 FFCore.ref(ScriptType::FFC, ffcref).a[reg - A(0)] = get_register(sarg1);
24280 else if(reg == SP)
24281 FFCore.ref(ScriptType::FFC, ffcref).sp = get_register(sarg1) / 10000;
24282 }
24283
24284 ///----------------------------------------------------------------------------------------------------//
24285 //Mathematical
24286
24287 void do_add(const bool v)
24288 {
24289 int32_t temp = SH::get_arg(sarg2, v);
24290 int32_t temp2 = get_register(sarg1);
24291
24292 set_register(sarg1, temp2 + temp);
24293 }
24294
24295 void do_sub(bool v, const bool inv = false)
24296 {
24297 bool v2 = false;
24298 if(inv) zc_swap(v,v2);
24299 auto destreg = (inv ? sarg2 : sarg1);
24300 int32_t temp = SH::get_arg(sarg2, v);
24301 int32_t temp2 = SH::get_arg(sarg1, v2);
24302 //zprint2("Subtraction found: '%d - %d' where '%s - %s'\n", temp2, temp, v2 ? "const" : "reg", v ? "const" : "reg");
24303 set_register(destreg, temp2 - temp);
24304 }
24305
24306 void do_mult(const bool v)
24307 {
24308 int64_t temp = SH::get_arg(sarg2, v);
24309 int32_t temp2 = get_register(sarg1);
24310
24311 set_register(sarg1, int32_t((temp * temp2) / 10000));
24312 }
24313
24314 708 void do_div(bool v, const bool inv = false)
24315 {
24316 708 bool v2 = false;
24317
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 708 times.
708 if(inv) zc_swap(v,v2);
24318
1/2
✓ Branch 0 taken 708 times.
✗ Branch 1 not taken.
708 auto destreg = (inv ? sarg2 : sarg1);
24319 708 int64_t temp = SH::get_arg(sarg2, v);
24320 708 int64_t temp2 = SH::get_arg(sarg1, v2);
24321
24322
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 696 times.
708 if(temp == 0)
24323 {
24324 12 Z_scripterrlog("Script attempted to divide %ld by zero!\n", temp2);
24325 12 set_register(destreg, int32_t(sign(temp2) * MAX_SIGNED_32));
24326 12 }
24327 else
24328 {
24329 696 set_register(destreg, int32_t((temp2 * 10000) / temp));
24330 }
24331 708 }
24332
24333 252 void do_mod(bool v, const bool inv = false)
24334 {
24335 252 bool v2 = false;
24336
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(inv) zc_swap(v,v2);
24337
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 auto destreg = (inv ? sarg2 : sarg1);
24338 252 int32_t temp = SH::get_arg(sarg2, v);
24339 252 int32_t temp2 = SH::get_arg(sarg1, v2);
24340
24341
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 240 times.
252 if(temp == 0)
24342 {
24343 12 Z_scripterrlog("Script attempted to modulo %ld by zero!\n",temp2);
24344 12 temp = 1;
24345 12 }
24346
24347 252 set_register(destreg, temp2 % temp);
24348 252 }
24349
24350 9368395 void do_trig(const bool v, const byte type)
24351 {
24352 9368395 double rangle = (SH::get_arg(sarg2, v) / 10000.0) * PI / 180.0;
24353
24354
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6163735 times.
✓ Branch 2 taken 3204584 times.
✓ Branch 3 taken 76 times.
9368395 switch(type)
24355 {
24356 case 0:
24357 6163735 set_register(sarg1, int32_t(zc::math::Sin(rangle) * 10000.0));
24358 6163735 break;
24359
24360 case 1:
24361 3204584 set_register(sarg1, int32_t(zc::math::Cos(rangle) * 10000.0));
24362 3204584 break;
24363
24364 case 2:
24365 76 set_register(sarg1, int32_t(zc::math::Tan(rangle) * 10000.0));
24366 76 break;
24367 }
24368 9368395 }
24369
24370 1263 void do_degtorad()
24371 {
24372 1263 double rangle = (SH::get_arg(sarg2, false) / 10000.0) * (PI / 180.0);
24373 1263 rangle += rangle < 0?-0.00005:0.00005;
24374
24375 1263 set_register(sarg1, int32_t(rangle * 10000.0));
24376 1263 }
24377
24378 59701 void do_radtodeg()
24379 {
24380 59701 double rangle = (SH::get_arg(sarg2, false) / 10000.0) * (180.0 / PI);
24381
24382 59701 set_register(sarg1, int32_t(rangle * 10000.0));
24383 59701 }
24384
24385 14918 void do_asin(const bool v)
24386 {
24387 14918 double temp = double(SH::get_arg(sarg2, v)) / 10000.0;
24388
24389
2/4
✓ Branch 0 taken 14918 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14918 times.
✗ Branch 3 not taken.
14918 if(temp >= -1 && temp <= 1)
24390 14918 set_register(sarg1, int32_t(asin(temp) * 10000.0));
24391 else
24392 {
24393 Z_scripterrlog("Script attempted to pass %ld into ArcSin!\n",temp);
24394 set_register(sarg1, -10000);
24395 }
24396 14918 }
24397
24398 void do_acos(const bool v)
24399 {
24400 double temp = double(SH::get_arg(sarg2, v)) / 10000.0;
24401
24402 if(temp >= -1 && temp <= 1)
24403 set_register(sarg1, int32_t(acos(temp) * 10000.0));
24404 else
24405 {
24406 Z_scripterrlog("Script attempted to pass %ld into ArcCos!\n",temp);
24407 set_register(sarg1, -10000);
24408 }
24409 }
24410
24411 863764 void do_arctan()
24412 {
24413 863764 double xpos = ri->d[rINDEX] / 10000.0;
24414 863764 double ypos = ri->d[rINDEX2] / 10000.0;
24415
24416 863764 set_register(sarg1, int32_t(atan2(ypos, xpos) * 10000.0));
24417 863764 }
24418
24419 void do_abs(const bool v)
24420 {
24421 int32_t temp = SH::get_arg(sarg1, v);
24422 set_register(sarg1, abs(temp));
24423 }
24424
24425 27 void do_log10(const bool v)
24426 {
24427 27 double temp = double(SH::get_arg(sarg1, v)) / 10000.0;
24428
24429
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(temp > 0)
24430 27 set_register(sarg1, int32_t(log10(temp) * 10000.0));
24431 else
24432 {
24433 Z_eventlog("Script tried to calculate log of %f\n", temp / 10000.0);
24434 set_register(sarg1, 0);
24435 }
24436 27 }
24437
24438 20 void do_naturallog(const bool v)
24439 {
24440 20 double temp = double(SH::get_arg(sarg1, v)) / 10000.0;
24441
24442
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 if(temp > 0)
24443 20 set_register(sarg1, int32_t(log(temp) * 10000.0));
24444 // else if(temp == 0)
24445 // {
24446 // Z_eventlog("Script tried to calculate ln of 0\n");
24447 // set_register(sarg1, MIN_SIGNED_32);
24448 // }
24449 else
24450 {
24451 Z_eventlog("Script tried to calculate ln of %f\n", temp / 10000.0);
24452 set_register(sarg1, 0);
24453 }
24454 20 }
24455
24456 void do_min(const bool v)
24457 {
24458 int32_t temp = SH::get_arg(sarg2, v);
24459 int32_t temp2 = get_register(sarg1);
24460 set_register(sarg1, zc_min(temp2, temp));
24461 }
24462
24463 void do_max(const bool v)
24464 {
24465 int32_t temp = SH::get_arg(sarg2, v);
24466 int32_t temp2 = get_register(sarg1);
24467
24468 set_register(sarg1, zc_max(temp2, temp));
24469 }
24470
24471
24472 2703958 void do_rnd(const bool v)
24473 {
24474 2703958 int32_t temp = SH::get_arg(sarg2, v) / 10000;
24475
24476
2/2
✓ Branch 0 taken 2703775 times.
✓ Branch 1 taken 183 times.
2703958 if(temp > 0)
24477 2703775 set_register(sarg1, (zc_oldrand() % temp) * 10000);
24478
1/2
✓ Branch 0 taken 183 times.
✗ Branch 1 not taken.
183 else if(temp < 0)
24479 183 set_register(sarg1, (zc_oldrand() % (-temp)) * -10000);
24480 else
24481 set_register(sarg1, 0); // Just return 0. (Do not log an error)
24482 2703958 }
24483
24484 void do_srnd(const bool v)
24485 {
24486 uint32_t seed = SH::get_arg(sarg1, v); //Do not `/10000`- allow the decimal portion to be used! -V
24487 zc_game_srand(seed);
24488 }
24489
24490 void do_srndrnd()
24491 {
24492 //Randomize the seed to the current system time, + or - the product of 2 random numbers.
24493 int32_t seed = time(0) + ((zc_rand() * int64_t(zc_rand())) * (zc_rand(1) ? 1 : -1));
24494 set_register(sarg1, seed);
24495 zc_game_srand(seed);
24496 }
24497
24498 //Returns the system Real-Time-Clock value for a specific type.
24499 void FFScript::getRTC(const bool v)
24500 {
24501 //int32_t type = get_register(sarg1) / 10000;
24502 //zprint("FFCore.getRTC() type == %d\n",type);
24503 //int32_t time = getTime(type);
24504 //zprint("FFCore.getRTC() time == %d\n",time);
24505 //zprint("FFCore.getRTC() time * 10000 == %d\n",time);
24506 //set_register(sarg1, getTime((byte)(SH::get_arg(sarg2, v) / 10000)) * 10000);
24507 set_register(sarg1, getTime((get_register(sarg1) / 10000)) * 10000);
24508 }
24509
24510
24511 void do_factorial(const bool v)
24512 {
24513 int32_t temp;
24514
24515 if(v)
24516 return; //must factorial a register, not a value (why is this exactly? ~Joe123)
24517 else
24518 {
24519 temp = get_register(sarg1) / 10000;
24520
24521 if(temp < 2)
24522 {
24523 set_register(sarg1, temp >= 0 ? 10000 : 00000);
24524 return;
24525 }
24526 }
24527
24528 int32_t temp2 = 1;
24529
24530 for(int32_t temp3 = temp; temp > 1; temp--)
24531 temp2 *= temp3;
24532
24533 set_register(sarg1, temp2 * 10000);
24534 }
24535
24536 77 void do_power(bool v, const bool inv = false)
24537 {
24538 77 bool v2 = false;
24539
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(inv) zc_swap(v,v2);
24540
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 auto destreg = (inv ? sarg2 : sarg1);
24541 77 double temp = double(SH::get_arg(sarg2, v)) / 10000.0;
24542 77 double temp2 = double(SH::get_arg(sarg1, v2)) / 10000.0;
24543
24544
3/4
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 40 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 37 times.
77 if(temp == 0 && temp2 == 0)
24545 {
24546 set_register(destreg, 10000);
24547 return;
24548 }
24549
24550 77 set_register(destreg, int32_t(pow(temp2, temp) * 10000.0));
24551 77 }
24552
24553 void do_lpower(bool v, const bool inv = false)
24554 {
24555 bool v2 = false;
24556 if(inv) zc_swap(v,v2);
24557 auto destreg = (inv ? sarg2 : sarg1);
24558 int32_t temp = SH::get_arg(sarg2, v);
24559 int32_t temp2 = SH::get_arg(sarg1, v2);
24560
24561 if(temp == 0 && temp2 == 0)
24562 {
24563 set_register(destreg, 1);
24564 return;
24565 }
24566
24567 set_register(destreg, int32_t(pow(temp2, temp)));
24568 }
24569
24570 //could use recursion or something to avoid truncation.
24571 void do_ipower(const bool v)
24572 {
24573 double sarg2val = double(SH::get_arg(sarg2, v));
24574 if ( sarg2val == 0 )
24575 {
24576 Z_scripterrlog("Division by 0 Err: InvPower() exponent divisor cannot be 0!!\n");
24577 set_register(sarg1, 1);
24578 return;
24579 }
24580 double temp = 10000.0 / sarg2val;
24581 double temp2 = double(get_register(sarg1)) / 10000.0;
24582
24583 if(temp == 0 && temp2 == 0)
24584 {
24585 Z_scripterrlog("Script attempted to calculate 0 to the power 0!\n");
24586 set_register(sarg1, 1);
24587 return;
24588 }
24589
24590 set_register(sarg1, int32_t(pow(temp2, temp) * 10000.0));
24591 }
24592
24593 2539388 void do_sqroot(const bool v)
24594 {
24595 2539388 double temp = double(SH::get_arg(sarg2, v)) / 10000.0;
24596
24597
2/2
✓ Branch 0 taken 422 times.
✓ Branch 1 taken 2538966 times.
2539388 if(temp < 0)
24598 {
24599 422 Z_scripterrlog("Script attempted to calculate square root of %ld!\n", temp);
24600 422 set_register(sarg1, -10000);
24601 422 return;
24602 }
24603
24604 2538966 set_register(sarg1, int32_t(sqrt(temp) * 10000.0));
24605 2539388 }
24606
24607 ///----------------------------------------------------------------------------------------------------//
24608 //Bitwise
24609
24610 void do_and(const bool v)
24611 {
24612 int32_t temp = SH::get_arg(sarg2, v) / 10000;
24613 int32_t temp2 = get_register(sarg1) / 10000;
24614 set_register(sarg1, (temp2 & temp) * 10000);
24615 }
24616
24617 34306 void do_and32(const bool v)
24618 {
24619 34306 int32_t temp = SH::get_arg(sarg2, v);
24620 34306 int32_t temp2 = get_register(sarg1);
24621 34306 set_register(sarg1, (temp2 & temp));
24622 34306 }
24623
24624 5733851 void do_or(const bool v)
24625 {
24626 5733851 int32_t temp = SH::get_arg(sarg2, v) / 10000;
24627 5733851 int32_t temp2 = get_register(sarg1) / 10000;
24628 5733851 set_register(sarg1, (temp2 | temp) * 10000);
24629 5733851 }
24630
24631 17 void do_or32(const bool v)
24632 {
24633 17 int32_t temp = SH::get_arg(sarg2, v);
24634 17 int32_t temp2 = get_register(sarg1);
24635 17 set_register(sarg1, (temp2 | temp));
24636 17 }
24637
24638 191297 void do_xor(const bool v)
24639 {
24640 191297 int32_t temp = SH::get_arg(sarg2, v) / 10000;
24641 191297 int32_t temp2 = get_register(sarg1) / 10000;
24642 191297 set_register(sarg1, (temp2 ^ temp) * 10000);
24643 191297 }
24644
24645 void do_xor32(const bool v)
24646 {
24647 int32_t temp = SH::get_arg(sarg2, v);
24648 int32_t temp2 = get_register(sarg1);
24649 set_register(sarg1, (temp2 ^ temp));
24650 }
24651
24652 void do_nand(const bool v)
24653 {
24654 int32_t temp = SH::get_arg(sarg2, v) / 10000;
24655 int32_t temp2 = get_register(sarg1) / 10000;
24656 set_register(sarg1, (~(temp2 & temp)) * 10000);
24657 }
24658
24659 void do_nor(const bool v)
24660 {
24661 int32_t temp = SH::get_arg(sarg2, v) / 10000;
24662 int32_t temp2 = get_register(sarg1) / 10000;
24663 set_register(sarg1, (~(temp2 | temp)) * 10000);
24664 }
24665
24666 void do_xnor(const bool v)
24667 {
24668 int32_t temp = SH::get_arg(sarg2, v) / 10000;
24669 int32_t temp2 = get_register(sarg1) / 10000;
24670 set_register(sarg1, (~(temp2 ^ temp)) * 10000);
24671 }
24672
24673 void do_not(const bool v)
24674 {
24675 int32_t temp = SH::get_arg(sarg2, v);
24676 set_register(sarg1, !temp);
24677 }
24678
24679 1427960 void do_bitwisenot(const bool v)
24680 {
24681 1427960 int32_t temp = SH::get_arg(sarg1, v) / 10000;
24682 1427960 set_register(sarg1, (~temp) * 10000);
24683 1427960 }
24684
24685 void do_bitwisenot32(const bool v)
24686 {
24687 int32_t temp = SH::get_arg(sarg1, v);
24688 set_register(sarg1, (~temp));
24689 }
24690
24691 62743713 void do_lshift(const bool v)
24692 {
24693 62743713 int32_t temp = SH::get_arg(sarg2, v) / 10000;
24694 62743713 int32_t temp2 = get_register(sarg1) / 10000;
24695 62743713 set_register(sarg1, (temp2 << temp) * 10000);
24696 62743713 }
24697
24698 22 void do_lshift32(const bool v)
24699 {
24700 22 int32_t temp = SH::get_arg(sarg2, v) / 10000;
24701 22 int32_t temp2 = get_register(sarg1);
24702 22 set_register(sarg1, (temp2 << temp));
24703 22 }
24704
24705 20517922 void do_rshift(const bool v)
24706 {
24707 20517922 int32_t temp = SH::get_arg(sarg2, v) / 10000;
24708 20517922 int32_t temp2 = get_register(sarg1) / 10000;
24709 20517922 set_register(sarg1, (temp2 >> temp) * 10000);
24710 20517922 }
24711
24712 34296 void do_rshift32(const bool v)
24713 {
24714 34296 int32_t temp = SH::get_arg(sarg2, v) / 10000;
24715 34296 int32_t temp2 = get_register(sarg1);
24716 34296 set_register(sarg1, (temp2 >> temp));
24717 34296 }
24718
24719 ///----------------------------------------------------------------------------------------------------//
24720 //Casting
24721
24722 void do_boolcast(const bool isFloat)
24723 {
24724 set_register(sarg1, (get_register(sarg1) ? (isFloat ? 1 : 10000) : 0));
24725 }
24726
24727 ///----------------------------------------------------------------------------------------------------//
24728 //Text ptr functions
24729 void do_fontheight()
24730 {
24731 int32_t font = get_register(sarg1)/10000;
24732 ri->d[rEXP1] = text_height(get_zc_font(font))*10000;
24733 }
24734
24735 13724 void do_strwidth()
24736 {
24737 13724 int32_t strptr = get_register(sarg1)/10000;
24738 13724 int32_t font = get_register(sarg2)/10000;
24739 13724 string the_string;
24740
1/2
✓ Branch 0 taken 13724 times.
✗ Branch 1 not taken.
13724 ArrayH::getString(strptr, the_string, 512);
24741
2/4
✓ Branch 0 taken 13724 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13724 times.
✗ Branch 3 not taken.
13724 ri->d[rEXP1] = text_length(get_zc_font(font), the_string.c_str())*10000;
24742 13724 }
24743
24744 15144 void do_charwidth()
24745 {
24746 15144 char chr = get_register(sarg1)/10000;
24747 15144 int32_t font = get_register(sarg2)/10000;
24748 15144 char *cstr = new char[2];
24749 15144 cstr[0] = chr;
24750 15144 cstr[1] = '\0';
24751 15144 ri->d[rEXP1] = text_length(get_zc_font(font), cstr)*10000;
24752
1/2
✓ Branch 0 taken 15144 times.
✗ Branch 1 not taken.
15144 delete[] cstr;
24753 15144 }
24754
24755 int32_t do_msgwidth(int32_t msg, char const* str)
24756 {
24757 if(BC::checkMessage(msg, str) != SH::_NoError)
24758 {
24759 return -1;
24760 }
24761
24762 int32_t v = text_length(get_zc_font(MsgStrings[msg].font),
24763 MsgStrings[msg].s.substr(0,MsgStrings[msg].s.find_last_not_of(' ')+1).c_str());
24764 return v;
24765 }
24766
24767 int32_t do_msgheight(int32_t msg, char const* str)
24768 {
24769 if(BC::checkMessage(msg, str) != SH::_NoError)
24770 {
24771 return -1;
24772 }
24773 return text_height(get_zc_font(MsgStrings[msg].font));
24774 }
24775
24776 ///----------------------------------------------------------------------------------------------------//
24777 //Gameplay functions
24778
24779 79 void do_warp(bool v)
24780 {
24781 79 int32_t dmapid = SH::get_arg(sarg1, v) / 10000;
24782 79 int32_t screenid = SH::get_arg(sarg2, v) / 10000;
24783
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 if ( ((unsigned)dmapid) >= MAXDMAPS )
24784 {
24785 Z_scripterrlog("Invalid DMap ID (%d) passed to Warp(). Aborting.\n", dmapid);
24786 return;
24787 }
24788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 if ( ((unsigned)screenid) >= MAPSCRS )
24789 {
24790 Z_scripterrlog("Invalid Screen ID (%d) passed to Warp(). Aborting.\n", screenid);
24791 return;
24792 }
24793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 if ( DMaps[dmapid].map*MAPSCRS+DMaps[dmapid].xoff+screenid >= (int32_t)TheMaps.size() )
24794 {
24795 Z_scripterrlog("Invalid destination passed to Warp(). Aborting.\n");
24796 return;
24797 }
24798 79 tmpscr->sidewarpdmap[0] = dmapid;
24799 79 tmpscr->sidewarpscr[0] = screenid;
24800 79 tmpscr->sidewarptype[0] = wtIWARP;
24801 79 Hero.ffwarp = true;
24802 79 }
24803
24804 126 void do_pitwarp(bool v)
24805 {
24806 126 int32_t dmapid = SH::get_arg(sarg1, v) / 10000;
24807 126 int32_t screenid = SH::get_arg(sarg2, v) / 10000;
24808
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if ( ((unsigned)dmapid) >= MAXDMAPS )
24809 {
24810 Z_scripterrlog("Invalid DMap ID (%d) passed to PitWarp(). Aborting.\n", dmapid);
24811 return;
24812 }
24813
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if ( ((unsigned)screenid) >= MAPSCRS )
24814 {
24815 Z_scripterrlog("Invalid Screen ID (%d) passed to PitWarp(). Aborting.\n", screenid);
24816 return;
24817 }
24818 //Extra sanity guard.
24819
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if ( DMaps[dmapid].map*MAPSCRS+DMaps[dmapid].xoff+screenid >= (int32_t)TheMaps.size() )
24820 {
24821 Z_scripterrlog("Invalid destination passed to Warp(). Aborting.\n");
24822 return;
24823 }
24824 126 tmpscr->sidewarpdmap[0] = dmapid;
24825 126 tmpscr->sidewarpscr[0] = screenid;
24826 126 tmpscr->sidewarptype[0] = wtIWARP;
24827 126 Hero.ffwarp = true;
24828 126 Hero.ffpit = true;
24829 126 }
24830
24831 void do_breakshield()
24832 {
24833 int32_t UID = get_register(sarg1);
24834
24835 for(int32_t j = 0; j < guys.Count(); j++)
24836 if(guys.spr(j)->getUID() == UID)
24837 {
24838 ((enemy*)guys.spr(j))->break_shield();
24839 return;
24840 }
24841 }
24842
24843 void do_showsavescreen()
24844 {
24845 bool didsaved = save_game(false, 0);
24846 set_register(sarg1, didsaved ? 10000 : 0);
24847 }
24848
24849 10848 void do_selectweapon(bool v, int32_t btn)
24850 {
24851
2/4
✓ Branch 0 taken 5268 times.
✓ Branch 1 taken 5580 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
10848 switch(btn)
24852 {
24853 case 1:
24854
1/2
✓ Branch 0 taken 5580 times.
✗ Branch 1 not taken.
5580 if(!get_qr(qr_SELECTAWPN))
24855 return;
24856 5580 break;
24857 case 2:
24858 if(!get_qr(qr_SET_XBUTTON_ITEMS))
24859 return;
24860 break;
24861 case 3:
24862 if(!get_qr(qr_SET_YBUTTON_ITEMS))
24863 return;
24864 break;
24865 }
24866
24867 10848 byte dir=(byte)(SH::get_arg(sarg1, v)/10000);
24868
24869 // Selection directions don't match the normal ones...
24870
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
✓ Branch 4 taken 10831 times.
10848 switch(dir)
24871 {
24872 case 0:
24873 dir=SEL_UP;
24874 break;
24875
24876 case 1:
24877 dir=SEL_DOWN;
24878 break;
24879
24880 case 2:
24881 17 dir=SEL_LEFT;
24882 17 break;
24883
24884 case 3:
24885 10831 dir=SEL_RIGHT;
24886 10831 break;
24887
24888 default:
24889 return;
24890 }
24891
24892
2/5
✗ Branch 0 not taken.
✓ Branch 1 taken 5268 times.
✓ Branch 2 taken 5580 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
10848 switch(btn)
24893 {
24894 case 0:
24895 5268 selectNextBWpn(dir);
24896 5268 break;
24897 case 1:
24898 5580 selectNextAWpn(dir);
24899 5580 break;
24900 case 2:
24901 selectNextXWpn(dir);
24902 break;
24903 case 3:
24904 selectNextYWpn(dir);
24905 break;
24906 }
24907 10848 }
24908
24909 ///----------------------------------------------------------------------------------------------------//
24910 //Screen Information
24911
24912 16270801 void do_issolid()
24913 {
24914 16270801 int32_t x = int32_t(ri->d[rINDEX] / 10000);
24915 16270801 int32_t y = int32_t(ri->d[rINDEX2] / 10000);
24916
24917 16270801 set_register(sarg1, (_walkflag(x, y, 1) ? 10000 : 0));
24918 16270801 }
24919
24920 void do_mapdataissolid()
24921 {
24922 if ( ri->mapsref == MAX_SIGNED_32 )
24923 {
24924 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","isSolid()");
24925 set_register(sarg1,10000);
24926 }
24927 else
24928 {
24929 //mapscr *m = GetMapscr(ri->mapsref);
24930 int32_t x = int32_t(ri->d[rINDEX] / 10000);
24931 int32_t y = int32_t(ri->d[rINDEX2] / 10000);
24932 switch(ri->mapsref)
24933 {
24934 case MAPSCR_TEMP0:
24935 set_register(sarg1, (_walkflag(x, y, 1)) ? 10000 : 0);
24936 break;
24937 case MAPSCR_SCROLL0:
24938 set_register(sarg1, (_walkflag(x, y, 1, FFCore.ScrollingScreens[0], FFCore.ScrollingScreens[1], FFCore.ScrollingScreens[2])) ? 10000 : 0);
24939 break;
24940 default:
24941 set_register(sarg1, (_walkflag(x, y, 1, GetMapscr(ri->mapsref)) ? 10000 : 0));
24942 }
24943 }
24944 }
24945
24946 void do_mapdataissolid_layer()
24947 {
24948 if ( ri->mapsref == MAX_SIGNED_32 )
24949 {
24950 Z_scripterrlog("Mapdata->%s pointer is either invalid or uninitialised","isSolidLayer()");
24951 set_register(sarg1,10000);
24952 }
24953 else
24954 {
24955 //mapscr *m = GetMapscr(ri->mapsref);
24956 int32_t x = int32_t(ri->d[rINDEX] / 10000);
24957 int32_t y = int32_t(ri->d[rINDEX2] / 10000);
24958 int32_t layer = int32_t(ri->d[rEXP1] / 10000);
24959 if(BC::checkBounds(layer, 0, 6, "mapdata->isSolidLayer()") != SH::_NoError)
24960 {
24961 set_register(sarg1,10000);
24962 }
24963 else
24964 {
24965 switch(ri->mapsref)
24966 {
24967 case MAPSCR_TEMP0:
24968 set_register(sarg1, (_walkflag_layer(x, y, 1, FFCore.tempScreens[layer])) ? 10000 : 0);
24969 break;
24970 case MAPSCR_SCROLL0:
24971 set_register(sarg1, (_walkflag_layer(x, y, 1, FFCore.ScrollingScreens[layer])) ? 10000 : 0);
24972 break;
24973 default:
24974 mapscr* m = GetMapscr(ri->mapsref);
24975 if(layer > 0)
24976 {
24977 if(m->layermap[layer] == 0)
24978 {
24979 set_register(sarg1,10000);
24980 break;
24981 }
24982 m = &TheMaps[(m->layermap[layer]*MAPSCRS + m->layerscreen[layer])];
24983 }
24984 set_register(sarg1, (_walkflag_layer(x, y, 1, m) ? 10000 : 0));
24985 break;
24986 }
24987 }
24988 }
24989 }
24990
24991 void do_issolid_layer()
24992 {
24993 int32_t x = int32_t(ri->d[rINDEX] / 10000);
24994 int32_t y = int32_t(ri->d[rINDEX2] / 10000);
24995 int32_t layer = int32_t(ri->d[rEXP1] / 10000);
24996 if(BC::checkBounds(layer, 0, 6, "Screen->isSolidLayer()") != SH::_NoError)
24997 {
24998 set_register(sarg1,10000);
24999 }
25000 else
25001 {
25002 set_register(sarg1, (_walkflag_layer(x, y, 1, FFCore.tempScreens[layer])) ? 10000 : 0);
25003 }
25004 }
25005
25006 249 void do_setsidewarp()
25007 {
25008 249 int32_t warp = SH::read_stack(ri->sp + 3) / 10000;
25009 249 int32_t scrn = SH::read_stack(ri->sp + 2) / 10000;
25010 249 int32_t dmap = SH::read_stack(ri->sp + 1) / 10000;
25011 249 int32_t type = SH::read_stack(ri->sp + 0) / 10000;
25012
25013
2/4
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
✗ Branch 3 not taken.
498 if(BC::checkBounds(warp, -1, 3, "Screen->SetSideWarp") != SH::_NoError ||
25014
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 BC::checkBounds(scrn, -1, 0x87, "Screen->SetSideWarp") != SH::_NoError ||
25015
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 BC::checkBounds(dmap, -1, MAXDMAPS - 1, "Screen->SetSideWarp") != SH::_NoError ||
25016 249 BC::checkBounds(type, -1, wtMAX - 1, "Screen->SetSideWarp") != SH::_NoError)
25017 return;
25018
25019
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if(scrn > -1)
25020 249 tmpscr->sidewarpscr[warp] = scrn;
25021
25022
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if(dmap > -1)
25023 249 tmpscr->sidewarpdmap[warp] = dmap;
25024
25025
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if(type > -1)
25026 249 tmpscr->sidewarptype[warp] = type;
25027 249 }
25028
25029 5 void do_settilewarp()
25030 {
25031 5 int32_t warp = SH::read_stack(ri->sp + 3) / 10000;
25032 5 int32_t scrn = SH::read_stack(ri->sp + 2) / 10000;
25033 5 int32_t dmap = SH::read_stack(ri->sp + 1) / 10000;
25034 5 int32_t type = SH::read_stack(ri->sp + 0) / 10000;
25035
25036
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
10 if(BC::checkBounds(warp, -1, 3, "Screen->SetTileWarp") != SH::_NoError ||
25037
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 BC::checkBounds(scrn, -1, 0x87, "Screen->SetTileWarp") != SH::_NoError ||
25038
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 BC::checkBounds(dmap, -1, MAXDMAPS - 1, "Screen->SetTileWarp") != SH::_NoError ||
25039 5 BC::checkBounds(type, -1, wtMAX - 1, "Screen->SetTileWarp") != SH::_NoError)
25040 return;
25041
25042
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(scrn > -1)
25043 5 tmpscr->tilewarpscr[warp] = scrn;
25044
25045
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(dmap > -1)
25046 5 tmpscr->tilewarpdmap[warp] = dmap;
25047
25048
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(type > -1)
25049 5 tmpscr->tilewarptype[warp] = type;
25050 5 }
25051
25052 354940 void do_getsidewarpdmap(const bool v)
25053 {
25054 354940 int32_t warp = SH::get_arg(sarg1, v) / 10000;
25055
25056
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354940 times.
354940 if(BC::checkBounds(warp, -1, 3, "Screen->GetSideWarpDMap") != SH::_NoError)
25057 {
25058 set_register(sarg1, -10000);
25059 return;
25060 }
25061
25062 354940 set_register(sarg1, tmpscr->sidewarpdmap[warp]*10000);
25063 354940 }
25064
25065 void do_getsidewarpscr(const bool v)
25066 {
25067 int32_t warp = SH::get_arg(sarg1, v) / 10000;
25068
25069 if(BC::checkBounds(warp, -1, 3, "Screen->GetSideWarpScreen") != SH::_NoError)
25070 {
25071 set_register(sarg1, -10000);
25072 return;
25073 }
25074
25075 set_register(sarg1, tmpscr->sidewarpscr[warp]*10000);
25076 }
25077
25078 void do_getsidewarptype(const bool v)
25079 {
25080 int32_t warp = SH::get_arg(sarg1, v) / 10000;
25081
25082 if(BC::checkBounds(warp, -1, 3, "Screen->GetSideWarpType") != SH::_NoError)
25083 {
25084 set_register(sarg1, -10000);
25085 return;
25086 }
25087
25088 set_register(sarg1, tmpscr->sidewarptype[warp]*10000);
25089 }
25090
25091 354943 void do_gettilewarpdmap(const bool v)
25092 {
25093 354943 int32_t warp = SH::get_arg(sarg1, v) / 10000;
25094
25095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354943 times.
354943 if(BC::checkBounds(warp, -1, 3, "Screen->GetTileWarpDMap") != SH::_NoError)
25096 {
25097 set_register(sarg1, -10000);
25098 return;
25099 }
25100
25101 354943 set_register(sarg1, tmpscr->tilewarpdmap[warp]*10000);
25102 354943 }
25103
25104 3 void do_gettilewarpscr(const bool v)
25105 {
25106 3 int32_t warp = SH::get_arg(sarg1, v) / 10000;
25107
25108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(BC::checkBounds(warp, -1, 3, "Screen->GetTileWarpScreen") != SH::_NoError)
25109 {
25110 set_register(sarg1, -10000);
25111 return;
25112 }
25113
25114 3 set_register(sarg1, tmpscr->tilewarpscr[warp]*10000);
25115 3 }
25116
25117 3 void do_gettilewarptype(const bool v)
25118 {
25119 3 int32_t warp = SH::get_arg(sarg1, v) / 10000;
25120
25121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(BC::checkBounds(warp, -1, 3, "Screen->GetTileWarpType") != SH::_NoError)
25122 {
25123 set_register(sarg1, -10000);
25124 return;
25125 }
25126
25127 3 set_register(sarg1, tmpscr->tilewarptype[warp]*10000);
25128 3 }
25129
25130 12696160 void do_layerscreen()
25131 {
25132 12696160 int32_t layer = (get_register(sarg2) / 10000) - 1;
25133
25134
3/4
✓ Branch 0 taken 12696160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10821826 times.
✓ Branch 3 taken 1874334 times.
12696160 if(BC::checkBounds(layer, 0, 5, "Screen->LayerScreen") != SH::_NoError ||
25135 12696160 tmpscr->layermap[layer] == 0)
25136 1874334 set_register(sarg1, -10000);
25137 else
25138 10821826 set_register(sarg1, tmpscr->layerscreen[layer] * 10000);
25139 12696160 }
25140
25141 16038753 void do_layermap()
25142 {
25143 16038753 int32_t layer = (get_register(sarg2) / 10000) - 1;
25144
25145
3/4
✓ Branch 0 taken 16038753 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13868561 times.
✓ Branch 3 taken 2170192 times.
16038753 if(BC::checkBounds(layer, 0, 5, "Screen->LayerMap") != SH::_NoError ||
25146 16038753 tmpscr->layermap[layer] == 0)
25147 2170192 set_register(sarg1, -10000);
25148 else
25149 13868561 set_register(sarg1, tmpscr->layermap[layer] * 10000);
25150 16038753 }
25151
25152
25153
25154
25155 60 void do_triggersecrets()
25156 {
25157 60 hidden_entrance(0, true, false, -4);
25158 //hidden_entrance(0,true,single16,scombo);
25159 //bool findentrance(int32_t x, int32_t y, int32_t flag, bool setflag)
25160 //We need a variation on these that triggers any combos with a given flag. -Z
25161 60 }
25162
25163
25164
25165
25166 void do_getscreenflags()
25167 {
25168 int32_t map = (ri->d[rEXP1] / 10000) - 1;
25169 int32_t scrn = ri->d[rINDEX2] / 10000;
25170 int32_t flagset = ri->d[rINDEX] / 10000;
25171
25172 if(BC::checkMapID(map, "Game->GetScreenFlags") != SH::_NoError ||
25173 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenFlags") != SH::_NoError ||
25174 BC::checkBounds(flagset, 0, 9, "Game->GetScreenFlags") != SH::_NoError)
25175 return;
25176
25177 set_register(sarg1, get_screenflags(&TheMaps[map * MAPSCRS + scrn], flagset));
25178 }
25179
25180 void do_getscreeneflags()
25181 {
25182 int32_t map = (ri->d[rEXP1] / 10000) - 1;
25183 int32_t scrn = ri->d[rINDEX2] / 10000;
25184 int32_t flagset = ri->d[rINDEX] / 10000;
25185
25186 if(BC::checkMapID(map, "Game->GetScreenEFlags") != SH::_NoError ||
25187 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenEFlags") != SH::_NoError ||
25188 BC::checkBounds(flagset, 0, 9, "Game->GetScreenEFlags") != SH::_NoError)
25189 return;
25190
25191 set_register(sarg1, get_screeneflags(&TheMaps[map * MAPSCRS + scrn], flagset));
25192 }
25193
25194 void FFScript::do_graphics_getpixel()
25195 {
25196 int32_t yoffset = 0;
25197 const bool brokenOffset= ( (get_er(er_BITMAPOFFSET)!=0) || (get_qr(qr_BITMAPOFFSETFIX)!=0) );
25198 int32_t ref = (ri->d[rEXP1]);
25199
25200 if ( ref == -10000 || ref == -20000 || ref >= 10000 ) //Bitmaps Loaded by LoadBitmapID have values of -10000 to 70000
25201 {
25202 ref /= 10000;
25203 }
25204 else ref -= 10; //Bitmaps other than those loaded by LoadBitmapID
25205
25206 BITMAP *bitty = FFCore.GetScriptBitmap(ref);
25207 int32_t xpos = ri->d[rINDEX2] / 10000;
25208
25209 if(!brokenOffset && ref == -1 )
25210 {
25211 yoffset = 56; //should this be -56?
25212 }
25213 else
25214 {
25215 yoffset = 0;
25216 }
25217
25218 int32_t ypos = (ri->d[rINDEX] / 10000)+yoffset;
25219 if(!bitty)
25220 {
25221 bitty = scrollbuf;
25222 }
25223
25224 int32_t ret = getpixel(bitty, xpos, ypos); //This is a palette index value.
25225
25226 if(!get_qr(qr_BROKEN_GETPIXEL_VALUE))
25227 ret *= 10000;
25228 set_register(sarg1, ret);
25229 }
25230
25231 //Some of these need to be reduced to two inputs. -Z
25232
25233 int32_t get_screendoor(mapscr *m, int32_t d)
25234 {
25235 int32_t f = m->door[d];
25236 return f*10000;
25237 }
25238
25239
25240
25241 int32_t get_screenlayeropacity(mapscr *m, int32_t d)
25242 {
25243 int32_t f = m->layeropacity[d]; //6 of these
25244 return f*10000;
25245 }
25246
25247 int32_t get_screensecretcombo(mapscr *m, int32_t d)
25248 {
25249 int32_t f = m->secretcombo[d]; //128 of these
25250 return f*10000;
25251 }
25252
25253 int32_t get_screensecretcset(mapscr *m, int32_t d)
25254 {
25255 int32_t f = m->secretcset[d]; //128 of these
25256 return f*10000;
25257 }
25258
25259 int32_t get_screensecretflag(mapscr *m, int32_t d)
25260 {
25261 int32_t f = m->secretflag[d]; //128 of these
25262 return f*10000;
25263 }
25264
25265 int32_t get_screenlayermap(mapscr *m, int32_t d)
25266 {
25267 int32_t f = m->layermap[d]; //6 of these
25268 return f*10000;
25269 }
25270
25271 int32_t get_screenlayerscreen(mapscr *m, int32_t d)
25272 {
25273 int32_t f = m->layerscreen[d]; //6 of these
25274 return f*10000;
25275 }
25276
25277 int32_t get_screenpath(mapscr *m, int32_t d)
25278 {
25279 int32_t f = m->path[d]; //4 of these
25280 return f*10000;
25281 }
25282
25283 int32_t get_screenwarpReturnX(mapscr *m, int32_t d)
25284 {
25285 int32_t f = m->warpreturnx[d]; //4 of these
25286 return f*10000;
25287 }
25288
25289 int32_t get_screenwarpReturnY(mapscr *m, int32_t d)
25290 {
25291 int32_t f = m->warpreturny[d]; //4 of these
25292 return f*10000;
25293 }
25294 //One too many inputs here. -Z
25295 int32_t get_screenGuy(mapscr *m)
25296 {
25297 int32_t f = m->guy;
25298 return f*10000;
25299 }
25300 //One too many inputs here. -Z
25301 int32_t get_screenString(mapscr *m)
25302 {
25303 int32_t f = m->str;
25304 return f*10000;
25305 }
25306 //One too many inputs here. -Z
25307 int32_t get_screenRoomtype(mapscr *m)
25308 {
25309 int32_t f = m->room;
25310 return f*10000;
25311 }
25312 //One too many inputs here. -Z
25313 int32_t get_screenEntryX(mapscr *m)
25314 {
25315 int32_t f = m->entry_x;
25316 return f*10000;
25317 }
25318 //One too many inputs here. -Z
25319 int32_t get_screenEntryY(mapscr *m)
25320 {
25321 int32_t f = m->entry_y;
25322 return f*10000;
25323 }
25324 //One too many inputs here. -Z
25325 int32_t get_screenitem(mapscr *m)
25326 {
25327 int32_t f = m->item;
25328 return f*10000;
25329 }
25330 //One too many inputs here. -Z
25331 int32_t get_screenundercombo(mapscr *m)
25332 {
25333 int32_t f = m->undercombo;
25334 return f*10000;
25335 }
25336 //One too many inputs here. -Z
25337 int32_t get_screenundercset(mapscr *m)
25338 {
25339 int32_t f = m->undercset;
25340 return f*10000;
25341 }
25342 //One too many inputs here. -Z
25343 int32_t get_screenatchall(mapscr *m)
25344 {
25345 int32_t f = m->catchall;
25346 return f*10000;
25347 }
25348 void do_getscreenLayerOpacity()
25349 {
25350 int32_t map = (ri->d[rEXP1] / 10000) - 1;
25351 int32_t scrn = ri->d[rINDEX2] / 10000;
25352 int32_t d = ri->d[rINDEX] / 10000;
25353
25354 if(BC::checkMapID(map, "Game->GetLayerOpacity(...map...)") != SH::_NoError ||
25355 BC::checkBounds(scrn, 0, 0x87, "Game->GetLayerOpacity(...screen...)") != SH::_NoError ||
25356 BC::checkBounds(d, 0, 6, "Game->GetLayerOpacity(...val...)") != SH::_NoError)
25357 return;
25358
25359 set_register(sarg1, get_screenlayeropacity(&TheMaps[map * MAPSCRS + scrn], d));
25360 }
25361 void do_getscreenSecretCombo()
25362 {
25363 int32_t map = (ri->d[rEXP1] / 10000) - 1;
25364 int32_t scrn = ri->d[rINDEX2] / 10000;
25365 int32_t d = ri->d[rINDEX] / 10000;
25366
25367 if(BC::checkMapID(map, "Game->GetSecretCombo(...map...)") != SH::_NoError ||
25368 BC::checkBounds(scrn, 0, 0x87, "Game->GetSecretCombo(...screen...)") != SH::_NoError ||
25369 BC::checkBounds(d, 0, 127, "Game->GetSecretCombo(...val...)") != SH::_NoError)
25370 return;
25371
25372 set_register(sarg1, get_screensecretcombo(&TheMaps[map * MAPSCRS + scrn], d));
25373 }
25374
25375 void do_getscreenSecretCSet()
25376 {
25377 int32_t map = (ri->d[rEXP1] / 10000) - 1;
25378 int32_t scrn = ri->d[rINDEX2] / 10000;
25379 int32_t d = ri->d[rINDEX] / 10000;
25380
25381 if(BC::checkMapID(map, "Game->GetSecretCSet(...map...)") != SH::_NoError ||
25382 BC::checkBounds(scrn, 0, 0x87, "Game->GetSecretCSet(...screen...)") != SH::_NoError ||
25383 BC::checkBounds(d, 0, 127, "Game->GetSecretCSet(...val...)") != SH::_NoError)
25384 return;
25385
25386 set_register(sarg1, get_screensecretcset(&TheMaps[map * MAPSCRS + scrn], d));
25387 }
25388
25389 void do_getscreenSecretFlag()
25390 {
25391 int32_t map = (ri->d[rEXP1] / 10000) - 1;
25392 int32_t scrn = ri->d[rINDEX2] / 10000;
25393 int32_t d = ri->d[rINDEX] / 10000;
25394
25395 if(BC::checkMapID(map, "Game->GetSecretFlag(...map...)") != SH::_NoError ||
25396 BC::checkBounds(scrn, 0, 0x87, "Game->GetSecretFlag(...screen...)") != SH::_NoError ||
25397 BC::checkBounds(d, 0,127, "Game->GetSecretFlag(...val...)") != SH::_NoError)
25398 return;
25399
25400 set_register(sarg1, get_screensecretflag(&TheMaps[map * MAPSCRS + scrn], d));
25401 }
25402 void do_getscreenLayerMap()
25403 {
25404 int32_t map = (ri->d[rEXP1] / 10000) - 1;
25405 int32_t scrn = ri->d[rINDEX2] / 10000;
25406 int32_t d = ri->d[rINDEX] / 10000;
25407
25408 if(BC::checkMapID(map, "Game->GetSreenLayerMap(...map...)") != SH::_NoError ||
25409 BC::checkBounds(scrn, 0, 0x87, "Game->GetSreenLayerMap(...screen...)") != SH::_NoError ||
25410 BC::checkBounds(d, 0, 6, "Game->GetSreenLayerMap(...val...)") != SH::_NoError)
25411 return;
25412
25413 set_register(sarg1, get_screenlayermap(&TheMaps[map * MAPSCRS + scrn], d));
25414 }
25415 void do_getscreenLayerscreen()
25416 {
25417 int32_t map = (ri->d[rEXP1] / 10000) - 1;
25418 int32_t scrn = ri->d[rINDEX2] / 10000;
25419 int32_t d = ri->d[rINDEX] / 10000;
25420
25421 if(BC::checkMapID(map, "Game->GetSreenLayerScreen(...map...)") != SH::_NoError ||
25422 BC::checkBounds(scrn, 0, 0x87, "Game->GetSreenLayerScreen(...screen...)") != SH::_NoError ||
25423 BC::checkBounds(d, 0, 6, "Game->GetSreenLayerScreen(...val...)") != SH::_NoError)
25424 return;
25425
25426 set_register(sarg1, get_screenlayerscreen(&TheMaps[map * MAPSCRS + scrn], d));
25427 }
25428 void do_getscreenPath()
25429 {
25430 int32_t map = (ri->d[rEXP1] / 10000) - 1;
25431 int32_t scrn = ri->d[rINDEX2] / 10000;
25432 int32_t d = ri->d[rINDEX] / 10000;
25433
25434 if(BC::checkMapID(map, "Game->GetSreenPath(...map...)") != SH::_NoError ||
25435 BC::checkBounds(scrn, 0, 0x87, "Game->GetSreenPath(...screen...)") != SH::_NoError ||
25436 BC::checkBounds(d, 0, 3, "Game->GetSreenPath(...val...)") != SH::_NoError)
25437 return;
25438
25439 set_register(sarg1, get_screenpath(&TheMaps[map * MAPSCRS + scrn], d));
25440 }
25441 void do_getscreenWarpReturnX()
25442 {
25443 int32_t map = (ri->d[rEXP1] / 10000) - 1;
25444 int32_t scrn = ri->d[rINDEX2] / 10000;
25445 int32_t d = ri->d[rINDEX] / 10000;
25446
25447 if(BC::checkMapID(map, "Game->GetScreenWarpReturnX(...map...)") != SH::_NoError ||
25448 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenWarpReturnX(...screen...)") != SH::_NoError ||
25449 BC::checkBounds(d, 0, 3, "Game->GetScreenWarpReturnX(...val...)") != SH::_NoError)
25450 return;
25451
25452 set_register(sarg1, get_screenwarpReturnX(&TheMaps[map * MAPSCRS + scrn], d));
25453 }
25454 void do_getscreenWarpReturnY()
25455 {
25456 int32_t map = (ri->d[rEXP1] / 10000) - 1;
25457 int32_t scrn = ri->d[rINDEX2] / 10000;
25458 int32_t d = ri->d[rINDEX] / 10000;
25459
25460 if(BC::checkMapID(map, "Game->GetScreenWarpReturnY(...map...)") != SH::_NoError ||
25461 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenWarpReturnY(...screen...)") != SH::_NoError ||
25462 BC::checkBounds(d, 0, 3, "Game->GetScreenWarpReturnY(...val...)") != SH::_NoError)
25463 return;
25464
25465 set_register(sarg1, get_screenwarpReturnY(&TheMaps[map * MAPSCRS + scrn], d));
25466 }
25467
25468 /*
25469 //One too many inputs here. -Z
25470 void do_getscreenatchall()
25471 {
25472 int32_t map = (ri->d[rEXP1] / 10000) - 1;
25473 int32_t scrn = ri->d[rINDEX2] / 10000;
25474 int32_t d = ri->d[rINDEX] / 10000;
25475
25476 if(BC::checkMapID(map, "Game->GetScreenCatchall(...map...)") != SH::_NoError ||
25477 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenCatchall(...screen...)") != SH::_NoError ||
25478 BC::checkBounds(d, 0, 6, "Game->GetScreenCatchall(...val...)") != SH::_NoError)
25479 return;
25480
25481 set_register(sarg1, get_screenatchall(&TheMaps[map * MAPSCRS + scrn], d));
25482 }
25483
25484
25485 //One too many inputs here. -Z
25486 void do_getscreenUndercombo()
25487 {
25488 int32_t map = (ri->d[rEXP1] / 10000) - 1;
25489 int32_t scrn = ri->d[rINDEX2] / 10000;
25490 int32_t d = ri->d[rINDEX] / 10000;
25491
25492 if(BC::checkMapID(map, "Game->GetcreenUndercombo(...map...)") != SH::_NoError ||
25493 BC::checkBounds(scrn, 0, 0x87, "Game->GetcreenUndercombo(...screen...)") != SH::_NoError ||
25494 BC::checkBounds(d, 0, 6, "Game->GetcreenUndercombo(...val...)") != SH::_NoError)
25495 return;
25496
25497 set_register(sarg1, get_screenundercombo(&TheMaps[map * MAPSCRS + scrn], d));
25498 }
25499 //One too many inputs here. -Z
25500 void do_getscreenUnderCSet()
25501 {
25502 int32_t map = (ri->d[rEXP1] / 10000) - 1;
25503 int32_t scrn = ri->d[rINDEX2] / 10000;
25504 int32_t d = ri->d[rINDEX] / 10000;
25505
25506 if(BC::checkMapID(map, "Game->GeScreenUnderCSet(...map...)") != SH::_NoError ||
25507 BC::checkBounds(scrn, 0, 0x87, "Game->GeScreenUnderCSet(...screen...)") != SH::_NoError ||
25508 BC::checkBounds(d, 0, 6, "Game->GeScreenUnderCSet(...val...)") != SH::_NoError)
25509 return;
25510
25511 set_register(sarg1, get_screenundercset(&TheMaps[map * MAPSCRS + scrn], d));
25512 }
25513
25514 //One too many inputs here. -Z
25515 void do_getscreenGuy()
25516 {
25517 int32_t map = (ri->d[rEXP1] / 10000) - 1;
25518 int32_t scrn = ri->d[rINDEX2] / 10000;
25519 int32_t d = ri->d[rINDEX] / 10000;
25520
25521 if(BC::checkMapID(map, "Game->GetScreenGuy(...map...)") != SH::_NoError ||
25522 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenGuy(...screen...)") != SH::_NoError ||
25523 BC::checkBounds(d, 0, 214747, "Game->GetScreenGuy(...val...)") != SH::_NoError)
25524 return;
25525
25526 set_register(sarg1, get_screenGuy(&TheMaps[map * MAPSCRS + scrn], d));
25527 }
25528 //One too many inputs here. -Z
25529 void do_getscreenString()
25530 {
25531 int32_t map = (ri->d[rEXP1] / 10000) - 1;
25532 int32_t scrn = ri->d[rINDEX2] / 10000;
25533 int32_t d = ri->d[rINDEX] / 10000;
25534
25535 if(BC::checkMapID(map, "Game->GetScreenString(...map...)") != SH::_NoError ||
25536 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenString(...screen...)") != SH::_NoError ||
25537 BC::checkBounds(d, 0, 214747, "Game->GetScreenString(...val...)") != SH::_NoError)
25538 return;
25539
25540 set_register(sarg1, get_screenString(&TheMaps[map * MAPSCRS + scrn], d));
25541 }
25542 //One too many inputs here. -Z
25543 void do_getscreenRoomType()
25544 {
25545 int32_t map = (ri->d[rEXP1] / 10000) - 1;
25546 int32_t scrn = ri->d[rINDEX2] / 10000;
25547 int32_t d = ri->d[rINDEX] / 10000;
25548
25549 if(BC::checkMapID(map, "Game->GetScreenRoomType(...map...)") != SH::_NoError ||
25550 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenRoomType(...screen...)") != SH::_NoError ||
25551 BC::checkBounds(d, 0, 214747, "Game->GetScreenRoomType(...val...)") != SH::_NoError)
25552 return;
25553
25554 set_register(sarg1, get_screenRoomtype(&TheMaps[map * MAPSCRS + scrn], d));
25555 }
25556 //One too many inputs here. -Z
25557 void do_getscreenEntryX()
25558 {
25559 int32_t map = (ri->d[rEXP1] / 10000) - 1;
25560 int32_t scrn = ri->d[rINDEX2] / 10000;
25561 int32_t d = ri->d[rINDEX] / 10000;
25562
25563 if(BC::checkMapID(map, "Game->GetScreenEntryX(...map...)") != SH::_NoError ||
25564 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenEntryX(...screen...)") != SH::_NoError ||
25565 BC::checkBounds(d, 0, 214747, "Game->GetScreenEntryX(...val...)") != SH::_NoError)
25566 return;
25567
25568 set_register(sarg1, get_screenEntryX(&TheMaps[map * MAPSCRS + scrn], d));
25569 }
25570 //One too many inputs here. -Z
25571 void do_getscreenEntryY()
25572 {
25573 int32_t map = (ri->d[rEXP1] / 10000) - 1;
25574 int32_t scrn = ri->d[rINDEX2] / 10000;
25575 int32_t d = ri->d[rINDEX] / 10000;
25576
25577 if(BC::checkMapID(map, "Game->GetScreenEntryY(...map...)") != SH::_NoError ||
25578 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenEntryY(...screen...)") != SH::_NoError ||
25579 BC::checkBounds(d, 0, 214747, "Game->GetScreenEntryY(...val...)") != SH::_NoError)
25580 return;
25581
25582 set_register(sarg1, get_screenEntryY(&TheMaps[map * MAPSCRS + scrn], d));
25583 }
25584 //One too many inputs here. -Z
25585 void do_getscreenItem()
25586 {
25587 int32_t map = (ri->d[rEXP1] / 10000) - 1;
25588 int32_t scrn = ri->d[rINDEX2] / 10000;
25589 int32_t d = ri->d[rINDEX] / 10000;
25590
25591 if(BC::checkMapID(map, "Game->GetScreenItem(...map...)") != SH::_NoError ||
25592 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenItem(...screen...)") != SH::_NoError ||
25593 BC::checkBounds(d, 0, 255, "Game->GetScreenItem(...val...)") != SH::_NoError)
25594 return;
25595
25596 set_register(sarg1, get_screenitem(&TheMaps[map * MAPSCRS + scrn], d));
25597 }
25598 */
25599 void do_getscreendoor()
25600 {
25601 int32_t map = (ri->d[rEXP1] / 10000) - 1;
25602 int32_t scrn = ri->d[rINDEX2] / 10000;
25603 int32_t door = ri->d[rINDEX] / 10000;
25604
25605 if(BC::checkMapID(map, "Game->GetScreenDoor(...map...)") != SH::_NoError ||
25606 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenDoor(...screen...)") != SH::_NoError ||
25607 BC::checkBounds(door, 0, 3, "Game->GetScreenDoor(...doorindex...)") != SH::_NoError)
25608 return;
25609
25610 set_register(sarg1, get_screendoor(&TheMaps[map * MAPSCRS + scrn], door));
25611 }
25612
25613 int32_t get_screennpc(mapscr *m, int32_t index)
25614 {
25615 int32_t f = m->enemy[index];
25616 return f*10000;
25617 }
25618
25619
25620 void do_getscreennpc()
25621 {
25622 int32_t map = (ri->d[rEXP1] / 10000) - 1;
25623 int32_t scrn = ri->d[rINDEX2] / 10000;
25624 int32_t enemy = ri->d[rINDEX] / 10000;
25625
25626 if(BC::checkMapID(map, "Game->GetScreenEnemy(...map...)") != SH::_NoError ||
25627 BC::checkBounds(scrn, 0, 0x87, "Game->GetScreenEnemy(...screen...)") != SH::_NoError ||
25628 BC::checkBounds(enemy, 0, 9, "Game->GetScreenEnemy(...enemy...)") != SH::_NoError)
25629 return;
25630
25631 set_register(sarg1, get_screennpc(&TheMaps[map * MAPSCRS + scrn], enemy));
25632 }
25633
25634
25635 ///----------------------------------------------------------------------------------------------------//
25636 //Pointer handling
25637
25638 4 void do_isvalidarray()
25639 {
25640 4 int32_t ptr = get_register(sarg1)/10000;
25641
25642 4 set_register(sarg1,0);
25643
25644
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!ptr) return;
25645
25646
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(ptr < 0) //An object array?
25647 {
25648 int32_t objptr = -ptr;
25649 auto it = objectRAM.find(objptr);
25650 if(it == objectRAM.end())
25651 return;
25652 set_register(sarg1,10000);
25653 }
25654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 else if(ptr >= NUM_ZSCRIPT_ARRAYS) //check global
25655 {
25656 dword gptr = ptr - NUM_ZSCRIPT_ARRAYS;
25657
25658 if(gptr > game->globalRAM.size())
25659 return;
25660 else set_register(sarg1,(game->globalRAM[gptr].Size() == 0) ? 0 : 10000); return;
25661 }
25662 else
25663 {
25664 4 set_register(sarg1,(localRAM[ptr].Size() == 0) ? 0 : 10000);
25665 }
25666 4 }
25667
25668 27033 void do_isvaliditem()
25669 {
25670 27033 int32_t IID = get_register(sarg1);
25671 //int32_t ct = items.Count();
25672
25673 //for ( int32_t j = items.Count()-1; j >= 0; --j )
25674
2/2
✓ Branch 0 taken 30321 times.
✓ Branch 1 taken 203 times.
30524 for(int32_t j = 0; j < items.Count(); j++)
25675 //for(int32_t j = 0; j < ct; j++)
25676
2/2
✓ Branch 0 taken 26830 times.
✓ Branch 1 taken 3491 times.
30321 if(items.spr(j)->getUID() == IID)
25677 {
25678 26830 set_register(sarg1, 10000);
25679 26830 return;
25680 }
25681
25682 203 set_register(sarg1, 0);
25683 27033 }
25684
25685 6259830 void do_isvalidnpc()
25686 {
25687 6259830 int32_t UID = get_register(sarg1);
25688 //for ( int32_t j = guys.Count()-1; j >= 0; --j )
25689 //int32_t ct = guys.Count();
25690
25691
2/2
✓ Branch 0 taken 20574989 times.
✓ Branch 1 taken 99922 times.
20674911 for(int32_t j = 0; j < guys.Count(); j++)
25692 //for(int32_t j = 0; j < ct; j++)
25693
2/2
✓ Branch 0 taken 6159908 times.
✓ Branch 1 taken 14415081 times.
20574989 if(guys.spr(j)->getUID() == UID)
25694 {
25695 6159908 set_register(sarg1, 10000);
25696 6159908 return;
25697 }
25698
25699 99922 set_register(sarg1, 0);
25700 6259830 }
25701
25702 593592 void do_isvalidlwpn()
25703 {
25704 593592 int32_t WID = get_register(sarg1);
25705 //int32_t ct = Lwpns.Count();
25706
25707 //for ( int32_t j = Lwpns.Count()-1; j >= 0; --j )
25708
2/2
✓ Branch 0 taken 2892378 times.
✓ Branch 1 taken 47556 times.
2939934 for(int32_t j = 0; j < Lwpns.Count(); j++)
25709 //for(int32_t j = 0; j < ct; j++)
25710
2/2
✓ Branch 0 taken 546036 times.
✓ Branch 1 taken 2346342 times.
2892378 if(Lwpns.spr(j)->getUID() == WID)
25711 {
25712 546036 set_register(sarg1, 10000);
25713 546036 return;
25714 }
25715
25716 47556 set_register(sarg1, 0);
25717 593592 }
25718
25719 122622 void do_isvalidewpn()
25720 {
25721 122622 int32_t WID = get_register(sarg1);
25722 // int32_t ct = Ewpns.Count();
25723
25724 // for ( int32_t j = Ewpns.Count()-1; j >= 0; --j )
25725
2/2
✓ Branch 0 taken 596698 times.
✓ Branch 1 taken 23727 times.
620425 for(int32_t j = 0; j < Ewpns.Count(); j++)
25726 //for(int32_t j = 0; j < ct; j++)
25727
2/2
✓ Branch 0 taken 98895 times.
✓ Branch 1 taken 497803 times.
596698 if(Ewpns.spr(j)->getUID() == WID)
25728 {
25729 98895 set_register(sarg1, 10000);
25730 98895 return;
25731 }
25732
25733 23727 set_register(sarg1, 0);
25734 122622 }
25735
25736 void do_lwpnmakeangular()
25737 {
25738 if(LwpnH::loadWeapon(ri->lwpn, "lweapon->MakeAngular") == SH::_NoError)
25739 {
25740 if (!LwpnH::getWeapon()->angular)
25741 {
25742 double vx;
25743 double vy;
25744 switch(NORMAL_DIR(LwpnH::getWeapon()->dir))
25745 {
25746 case l_up:
25747 case l_down:
25748 case left:
25749 vx = -1.0*((weapon*)s)->step;
25750 break;
25751 case r_down:
25752 case r_up:
25753 case right:
25754 vx = ((weapon*)s)->step;
25755 break;
25756
25757 default:
25758 vx = 0;
25759 break;
25760 }
25761 switch(NORMAL_DIR(LwpnH::getWeapon()->dir))
25762 {
25763 case l_up:
25764 case r_up:
25765 case up:
25766 vy = -1.0*((weapon*)s)->step;
25767 break;
25768 case l_down:
25769 case r_down:
25770 case down:
25771 vy = ((weapon*)s)->step;
25772 break;
25773
25774 default:
25775 vy = 0;
25776 break;
25777 }
25778 LwpnH::getWeapon()->angular = true;
25779 LwpnH::getWeapon()->angle=atan2(vy, vx);
25780 LwpnH::getWeapon()->step=FFCore.Distance(0, 0, vx, vy)/10000.0;
25781 LwpnH::getWeapon()->doAutoRotate();
25782 }
25783 }
25784 }
25785
25786 void do_lwpnmakedirectional()
25787 {
25788 if(LwpnH::loadWeapon(ri->lwpn, "lweapon->MakeDirectional") == SH::_NoError)
25789 {
25790 if (LwpnH::getWeapon()->angular)
25791 {
25792 LwpnH::getWeapon()->dir = NORMAL_DIR(AngleToDir(WrapAngle(LwpnH::getWeapon()->angle)));
25793 LwpnH::getWeapon()->angular = false;
25794 LwpnH::getWeapon()->doAutoRotate(true);
25795 }
25796 }
25797 }
25798
25799 void do_ewpnmakeangular()
25800 {
25801 if(EwpnH::loadWeapon(ri->ewpn, "eweapon->MakeAngular") == SH::_NoError)
25802 {
25803 if (!EwpnH::getWeapon()->angular)
25804 {
25805 double vx;
25806 double vy;
25807 switch(NORMAL_DIR(EwpnH::getWeapon()->dir))
25808 {
25809 case l_up:
25810 case l_down:
25811 case left:
25812 vx = -1.0*((weapon*)s)->step;
25813 break;
25814 case r_down:
25815 case r_up:
25816 case right:
25817 vx = ((weapon*)s)->step;
25818 break;
25819
25820 default:
25821 vx = 0;
25822 break;
25823 }
25824 switch(NORMAL_DIR(EwpnH::getWeapon()->dir))
25825 {
25826 case l_up:
25827 case r_up:
25828 case up:
25829 vy = -1.0*((weapon*)s)->step;
25830 break;
25831 case l_down:
25832 case r_down:
25833 case down:
25834 vy = ((weapon*)s)->step;
25835 break;
25836
25837 default:
25838 vy = 0;
25839 break;
25840 }
25841 EwpnH::getWeapon()->angular = true;
25842 EwpnH::getWeapon()->angle=atan2(vy, vx);
25843 EwpnH::getWeapon()->step=FFCore.Distance(0, 0, vx, vy)/10000.0;
25844 EwpnH::getWeapon()->doAutoRotate();
25845 }
25846 }
25847 }
25848
25849 void do_ewpnmakedirectional()
25850 {
25851 if(EwpnH::loadWeapon(ri->lwpn, "eweapon->MakeDirectional") == SH::_NoError)
25852 {
25853 if (EwpnH::getWeapon()->angular)
25854 {
25855 EwpnH::getWeapon()->dir = NORMAL_DIR(AngleToDir(WrapAngle(EwpnH::getWeapon()->angle)));
25856 EwpnH::getWeapon()->angular = false;
25857 EwpnH::getWeapon()->doAutoRotate(true);
25858 }
25859 }
25860 }
25861
25862 15079 void do_lwpnusesprite(const bool v)
25863 {
25864 15079 int32_t ID = SH::get_arg(sarg1, v) / 10000;
25865
25866
1/2
✓ Branch 0 taken 15079 times.
✗ Branch 1 not taken.
15079 if(BC::checkWeaponMiscSprite(ID, "lweapon->UseSprite") != SH::_NoError)
25867 return;
25868
25869
1/2
✓ Branch 0 taken 15079 times.
✗ Branch 1 not taken.
15079 if(LwpnH::loadWeapon(ri->lwpn, "lweapon->UseSprite") == SH::_NoError)
25870 15079 LwpnH::getWeapon()->LOADGFX(ID);
25871 15079 }
25872
25873 132144 void do_ewpnusesprite(const bool v)
25874 {
25875 132144 int32_t ID = SH::get_arg(sarg1, v) / 10000;
25876
25877
1/2
✓ Branch 0 taken 132144 times.
✗ Branch 1 not taken.
132144 if(BC::checkWeaponMiscSprite(ID, "eweapon->UseSprite") != SH::_NoError)
25878 return;
25879
25880
1/2
✓ Branch 0 taken 132144 times.
✗ Branch 1 not taken.
132144 if(EwpnH::loadWeapon(ri->ewpn, "eweapon->UseSprite") == SH::_NoError)
25881 132144 EwpnH::getWeapon()->LOADGFX(ID);
25882 132144 }
25883
25884 void do_portalusesprite()
25885 {
25886 int32_t ID = get_register(sarg1) / 10000;
25887
25888 if(BC::checkWeaponMiscSprite(ID, "portal->UseSprite") != SH::_NoError)
25889 return;
25890
25891 if(portal* p = checkPortal(ri->portalref, "UseSprite()"))
25892 p->LOADGFX(ID);
25893 }
25894
25895 void do_clearsprites(const bool v)
25896 {
25897 int32_t spritelist = SH::get_arg(sarg1, v) / 10000;
25898
25899 if(BC::checkBounds(spritelist, 0, 5, "Screen->ClearSprites") != SH::_NoError)
25900 return;
25901
25902 switch(spritelist)
25903 {
25904 case 0:
25905 guys.clear();
25906 break;
25907
25908 case 1:
25909 items.clear();
25910 break;
25911
25912 case 2:
25913 Ewpns.clear();
25914 break;
25915
25916 case 3:
25917 Lwpns.clear();
25918 Hero.reset_hookshot();
25919 break;
25920
25921 case 4:
25922 decorations.clear();
25923 break;
25924
25925 case 5:
25926 particles.clear();
25927 break;
25928 }
25929 }
25930
25931 1201098 void do_loadlweapon(const bool v)
25932 {
25933 1201098 int32_t index = SH::get_arg(sarg1, v) / 10000;
25934
25935
2/2
✓ Branch 0 taken 13756 times.
✓ Branch 1 taken 1187342 times.
1201098 if(BC::checkLWeaponIndex(index, "Screen->LoadLWeapon") != SH::_NoError)
25936 13756 ri->lwpn = 0; //MAX_DWORD; //Now NULL
25937 else
25938 {
25939 1187342 ri->lwpn = Lwpns.spr(index)->getUID();
25940 // This is too trivial to log. -L
25941 //Z_eventlog("Script loaded lweapon with UID = %ld\n", ri->lwpn);
25942 }
25943 1201098 }
25944
25945 2753647 void do_loadeweapon(const bool v)
25946 {
25947 2753647 int32_t index = SH::get_arg(sarg1, v) / 10000;
25948
25949
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2753647 times.
2753647 if(BC::checkEWeaponIndex(index, "Screen->LoadEWeapon") != SH::_NoError)
25950 ri->ewpn = 0; //MAX_DWORD; //Now NULL
25951 else
25952 {
25953 2753647 ri->ewpn = Ewpns.spr(index)->getUID();
25954 //Z_eventlog("Script loaded eweapon with UID = %ld\n", ri->ewpn);
25955 }
25956 2753647 }
25957
25958 136832 void do_loaditem(const bool v)
25959 {
25960 136832 int32_t index = SH::get_arg(sarg1, v) / 10000;
25961
25962
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 136832 times.
136832 if(BC::checkItemIndex(index, "Screen->LoadItem") != SH::_NoError)
25963 ri->itemref = 0; //MAX_DWORD; //Now NULL
25964 else
25965 {
25966 136832 ri->itemref = items.spr(index)->getUID();
25967 //Z_eventlog("Script loaded item with UID = %ld\n", ri->itemref);
25968 }
25969 136832 }
25970
25971
25972 55814 void do_loaditemdata(const bool v)
25973 {
25974 55814 int32_t ID = SH::get_arg(sarg1, v) / 10000;
25975
25976 //I *think* this is the right check ~Joe
25977
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55814 times.
55814 if(BC::checkItemID(ID, "Game->LoadItemData") != SH::_NoError)
25978 {
25979 ri->idata = -1; //new null value
25980 return;
25981 }
25982 55814 ri->idata = ID;
25983 //Z_eventlog("Script loaded itemdata with ID = %ld\n", ri->idata);
25984 55814 }
25985
25986 15641785 void do_loadnpc(const bool v)
25987 {
25988 15641785 int32_t index = SH::get_arg(sarg1, v) / 10000;
25989
25990
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 15641704 times.
15641785 if(BC::checkGuyIndex(index, "Screen->LoadNPC") != SH::_NoError)
25991 81 ri->guyref = 0; // MAX_DWORD;
25992 else
25993 {
25994 15641704 ri->guyref = guys.spr(index)->getUID();
25995 //Z_eventlog("Script loaded NPC with UID = %ld\n", ri->guyref);
25996 }
25997 15641785 }
25998
25999 755007 void FFScript::do_loaddmapdata(const bool v)
26000 {
26001 755007 int32_t ID = SH::get_arg(sarg1, v) / 10000;
26002
26003
2/4
✓ Branch 0 taken 755007 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 755007 times.
755007 if ( ID < 0 || ID > 511 )
26004 {
26005 Z_scripterrlog("Invalid DMap ID passed to Game->LoadDMapData(): %d\n", ID);
26006 ri->dmapsref = MAX_DWORD;
26007 }
26008
26009 755007 else ri->dmapsref = ID;
26010 //Z_eventlog("Script loaded npcdata with ID = %ld\n", ri->idata);
26011 755007 }
26012
26013 22 void FFScript::do_loadrng()
26014 {
26015 22 ri->rngref = get_free_rng();
26016 22 ri->d[rEXP1] = ri->rngref;
26017 22 }
26018
26019 void FFScript::do_loaddirectory()
26020 {
26021 int32_t arrayptr = get_register(sarg1) / 10000;
26022 string path;
26023 ArrayH::getString(arrayptr, path, 2048);
26024
26025 if(path.find("../") != string::npos
26026 || path.find("..\\") != string::npos)
26027 {
26028 Z_scripterrlog("Error: Script attempted to go up a directory in directory load '%s'\n", path.c_str());
26029 return;
26030 }
26031
26032 size_t pos = path.find_last_not_of("/\\");
26033 if(pos != string::npos && !(path.find_last_of("/\\") < pos))
26034 path = path.substr(0, pos+1);
26035 char buf[2048+1] = {0};
26036 get_scriptfile_path(buf, path.c_str());
26037 regulate_path(buf);
26038 if(valid_dir(buf) && checkPath(buf, true))
26039 {
26040 ri->directoryref = get_free_directory(false);
26041 if(!ri->directoryref) return;
26042 user_dir* d = checkDir(ri->directoryref, "LoadDirectory", true);
26043 set_register(sarg1, ri->directoryref);
26044 d->setPath(buf);
26045 return;
26046 }
26047 Z_scripterrlog("Path '%s' empty or points to a file; must point to a directory!\n",path.c_str());
26048 ri->directoryref = 0;
26049 set_register(sarg1, 0);
26050 }
26051
26052 void FFScript::do_loadstack()
26053 {
26054 ri->stackref = get_free_stack();
26055 ri->d[rEXP1] = ri->stackref;
26056 }
26057
26058 void FFScript::do_loaddropset(const bool v)
26059 {
26060 int32_t ID = SH::get_arg(sarg1, v) / 10000;
26061
26062 if ( ID < 0 || ID > MAXITEMDROPSETS )
26063 {
26064 Z_scripterrlog("Invalid Dropset ID passed to Game->LoadDropset(): %d\n", ID);
26065 ri->dropsetref = MAX_DWORD;
26066 }
26067
26068 else ri->dropsetref = ID;
26069 }
26070
26071 void FFScript::do_loadbottle(const bool v)
26072 {
26073 int32_t ID = SH::get_arg(sarg1, v) / 10000;
26074
26075 if ( ID < 1 || ID > 64 )
26076 {
26077 Z_scripterrlog("Invalid BottleType ID passed to Game->LoadBottleData(): %d\n", ID);
26078 ri->bottletyperef = 0;
26079 }
26080 else ri->bottletyperef = ID;
26081 }
26082
26083 void FFScript::do_loadbottleshop(const bool v)
26084 {
26085 int32_t ID = SH::get_arg(sarg1, v) / 10000;
26086
26087 if ( ID < 0 || ID > 255 )
26088 {
26089 Z_scripterrlog("Invalid BottleShopType ID passed to Game->LoadBottleShopData(): %d\n", ID);
26090 ri->bottleshopref = 0;
26091 }
26092 else ri->bottleshopref = ID+1;
26093 }
26094 68 void FFScript::do_loadgenericdata(const bool v)
26095 {
26096 68 int32_t ID = SH::get_arg(sarg1, v) / 10000;
26097
26098
2/4
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 68 times.
68 if ( ID < 1 || ID > NUMSCRIPTSGENERIC )
26099 {
26100 Z_scripterrlog("Invalid GenericData ID passed to Game->LoadGenericData(): %d\n", ID);
26101 ri->genericdataref = 0;
26102 }
26103 68 else ri->genericdataref = ID;
26104 68 }
26105
26106 void FFScript::do_create_paldata()
26107 {
26108 ri->paldataref = get_free_paldata();
26109 user_paldata* pd = &script_paldatas[ri->paldataref-1];
26110 for (int32_t q = 0; q < PALDATA_BITSTREAM_SIZE; ++q)
26111 pd->colors_used[q] = 0;
26112 ri->d[rEXP1] = ri->paldataref;
26113 }
26114
26115 void FFScript::do_create_paldata_clr()
26116 {
26117 ri->paldataref = get_free_paldata();
26118 user_paldata* pd = &script_paldatas[ri->paldataref - 1];
26119 int32_t clri = get_register(sarg1);
26120
26121 RGB c = _RGB((clri >> 16) & 0xFF, (clri >> 8) & 0xFF, clri & 0xFF);
26122
26123 if (c.r < 0 || c.g < 0 || c.b < 0)
26124 {
26125 Z_scripterrlog("Invalid rgb (%d) passed to Graphics->CreatePalData().\n", clri);
26126 }
26127 c.r = vbound(c.r, 0, 63);
26128 c.g = vbound(c.g, 0, 63);
26129 c.b = vbound(c.b, 0, 63);
26130
26131 for(int32_t q = 0; q < 240; ++q)
26132 pd->set_color(q, c);
26133 ri->d[rEXP1] = ri->paldataref;
26134 }
26135
26136 void FFScript::do_mix_clr()
26137 {
26138 int32_t clr_start = SH::read_stack(ri->sp + 3);
26139 int32_t clr_end = SH::read_stack(ri->sp + 2);
26140 float percent = SH::read_stack(ri->sp + 1) / 10000.0;
26141 int32_t color_space = SH::read_stack(ri->sp + 0) / 10000;
26142
26143 RGB ref1c = _RGB((clr_start >> 16) & 0xFF, (clr_start >> 8) & 0xFF, clr_start & 0xFF);
26144 RGB ref2c = _RGB((clr_end >> 16) & 0xFF, (clr_end >> 8) & 0xFF, clr_end & 0xFF);
26145 RGB outputc = user_paldata::mix_color(ref1c, ref2c, percent, color_space);
26146
26147 int32_t r = vbound(outputc.r, 0, 63);
26148 int32_t g = vbound(outputc.g, 0, 63);
26149 int32_t b = vbound(outputc.b, 0, 63);
26150
26151 ri->d[rEXP1] = (r << 16) | (g << 8) | b;
26152 }
26153
26154 void FFScript::do_create_rgb_hex()
26155 {
26156 int32_t hexrgb = get_register(sarg1);
26157
26158 int32_t r = (hexrgb >> 16) & 0xFF;
26159 int32_t g = (hexrgb >> 8) & 0xFF;
26160 int32_t b = hexrgb & 0xFF;
26161
26162 //Convert rgb from 8-bit to 6-bit
26163 r = vbound(r / 4, 0, 63);
26164 g = vbound(g / 4, 0, 63);
26165 b = vbound(b / 4, 0, 63);
26166
26167 ri->d[rEXP1] = (r << 16) | (g << 8) | b;
26168 }
26169
26170 void FFScript::do_create_rgb()
26171 {
26172 int32_t r = SH::read_stack(ri->sp + 2) / 10000;
26173 int32_t g = SH::read_stack(ri->sp + 1) / 10000;
26174 int32_t b = SH::read_stack(ri->sp + 0) / 10000;
26175
26176 if (unsigned(r) > 63 || unsigned(g) > 63 || unsigned(b) > 63)
26177 {
26178 Z_scripterrlog("R/G/B values passed to Graphics->CreateRGB() should range from 0-63.\n");
26179 }
26180 r = vbound(r, 0, 63);
26181 g = vbound(g, 0, 63);
26182 b = vbound(b, 0, 63);
26183
26184 ri->d[rEXP1] = (r << 16) | (g << 8) | b;
26185 }
26186
26187 void FFScript::do_convert_from_rgb()
26188 {
26189 int32_t buf = SH::read_stack(ri->sp + 2) / 10000;
26190 int32_t clri = SH::read_stack(ri->sp + 1);
26191 int32_t color_space = SH::read_stack(ri->sp + 0) / 10000;
26192
26193 ArrayManager am(buf);
26194 if (am.invalid()) return;
26195 int32_t zscript_array_size = am.size();
26196 int32_t target_size;
26197
26198 switch (color_space)
26199 {
26200 case user_paldata::CSPACE_CMYK:
26201 target_size = 4;
26202 break;
26203 default:
26204 target_size = 3;
26205 }
26206
26207 if (zscript_array_size < target_size)
26208 {
26209 Z_scripterrlog("Array supplied to 'Graphics->ConvertFromRGB' not large enough. Should be at least size %d\n", target_size);
26210 return;
26211 }
26212
26213 RGB c = _RGB((clri >> 16) & 0xFF, (clri >> 8) & 0xFF, clri & 0xFF);
26214 double convert[4];
26215 user_paldata::RGBTo(c, convert, color_space);
26216
26217 for (int32_t q = 0; q < target_size; ++q)
26218 {
26219 am.set(q, int32_t(convert[q]*10000));
26220 }
26221
26222 return;
26223 }
26224
26225 void FFScript::do_convert_to_rgb()
26226 {
26227 int32_t buf = SH::read_stack(ri->sp + 1) / 10000;
26228 int32_t color_space = SH::read_stack(ri->sp + 0) / 10000;
26229
26230 ArrayManager am(buf);
26231 if (am.invalid()) return;
26232 int32_t zscript_array_size = am.size();
26233 int32_t target_size;
26234
26235 switch (color_space)
26236 {
26237 case user_paldata::CSPACE_CMYK:
26238 target_size = 4;
26239 break;
26240 default:
26241 target_size = 3;
26242 }
26243
26244 if (zscript_array_size < target_size)
26245 {
26246 Z_scripterrlog("Array supplied to 'Graphics->ConvertToRGB' not large enough. Should be at least size %d\n", target_size);
26247 return;
26248 }
26249
26250 double convert[4];
26251 for (int32_t q = 0; q < target_size; ++q)
26252 {
26253 convert[q] = am.get(q) / 10000.0;
26254 }
26255 RGB c = user_paldata::RGBFrom(convert, color_space);
26256
26257 ri->d[rEXP1] = (c.r << 16) | (c.g << 8) | c.b;
26258 }
26259
26260 void FFScript::do_paldata_load_level()
26261 {
26262 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->LoadLevelPalette()"))
26263 {
26264 int32_t lvl = get_register(sarg1) / 10000;
26265 //Load CSets 2-4
26266 pd->load_cset(2, lvl * pdLEVEL + poLEVEL + 0);
26267 pd->load_cset(3, lvl * pdLEVEL + poLEVEL + 1);
26268 pd->load_cset(4, lvl * pdLEVEL + poLEVEL + 2);
26269 //Load CSet 9
26270 pd->load_cset(9, lvl * pdLEVEL + poLEVEL + 3);
26271 //Load 1, 5, 7, 8
26272 pd->load_cset(1, lvl * pdLEVEL + poNEWCSETS);
26273 pd->load_cset(5, lvl * pdLEVEL + poNEWCSETS + 1);
26274 pd->load_cset(7, lvl * pdLEVEL + poNEWCSETS + 2);
26275 pd->load_cset(8, lvl * pdLEVEL + poNEWCSETS + 3);
26276 }
26277 return;
26278 }
26279
26280 void FFScript::do_paldata_load_sprite()
26281 {
26282 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->LoadSpritePalette()"))
26283 {
26284 int32_t page = get_register(sarg1) / 10000;
26285
26286 int32_t pageoffset = 0;
26287 switch (page)
26288 {
26289 case 0: pageoffset += 0; break;
26290 case 1: pageoffset += 15; break;
26291 default:
26292 Z_scripterrlog("Invalid page (%d) passed to paldata->LoadSpritePalette(). Valid pages are 0 or 1. Aborting.\n", page);
26293 return;
26294 }
26295 for (int32_t q = 0; q < 15; ++q)
26296 {
26297 pd->load_cset(q, poSPRITE255 + pageoffset + q);
26298 }
26299 }
26300 return;
26301 }
26302
26303 void FFScript::do_paldata_load_main()
26304 {
26305 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->LoadMainPalette()"))
26306 {
26307 for (int32_t q = 0; q <= 15; ++q)
26308 {
26309 pd->load_cset_main(q);
26310 }
26311 }
26312 return;
26313 }
26314
26315 void FFScript::do_paldata_load_cycle()
26316 {
26317 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->LoadCyclePalette()"))
26318 {
26319 int32_t lvl = get_register(sarg1) / 10000;
26320 for (int32_t q = 4; q <= 12; ++q)
26321 {
26322 pd->load_cset(q, lvl * pdLEVEL + poLEVEL + q);
26323 }
26324 }
26325 return;
26326 }
26327
26328 void FFScript::do_paldata_load_bitmap()
26329 {
26330 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->LoadBitmapPalette()"))
26331 {
26332 int32_t pathptr = get_register(sarg1) / 10000;
26333 string str;
26334 ArrayH::getString(pathptr, str, 256);
26335
26336 if (get_qr(qr_BITMAP_AND_FILESYSTEM_PATHS_ALWAYS_RELATIVE))
26337 {
26338 char buf[2048+1] = { 0 };
26339 if (FFCore.get_scriptfile_path(buf, str.c_str()))
26340 str = buf;
26341 }
26342 regulate_path(str);
26343
26344 if (str.empty())
26345 {
26346 al_trace("String pointer is null! Internal error. \n");
26347 return;
26348 }
26349
26350 PALETTE tempPal;
26351 get_palette(tempPal);
26352 if (checkPath(str.c_str(), false))
26353 {
26354 BITMAP* bmp = load_bitmap(str.c_str(), tempPal);
26355 if (!bmp)
26356 {
26357 Z_scripterrlog("LoadBitmapPalette() failed to load image file %s.\n", str.c_str());
26358 }
26359 else
26360 {
26361 for (int32_t q = 0; q < PALDATA_NUM_COLORS; ++q)
26362 {
26363 pd->colors[q] = tempPal[q];
26364 set_bit(pd->colors_used, q, true);
26365 }
26366 }
26367 destroy_bitmap(bmp);
26368 }
26369 else
26370 {
26371 Z_scripterrlog("Failed to load image file: %s. File not found.\n", str.c_str());
26372 }
26373 }
26374 return;
26375 }
26376
26377 void FFScript::do_paldata_write_level()
26378 {
26379 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->WriteLevelPalette()"))
26380 {
26381 int32_t lvl = get_register(sarg1) / 10000;
26382 bool changed = false;
26383 //Write CSets 2-4
26384 if (pd->check_cset(2, lvl * pdLEVEL + poLEVEL + 0))
26385 {
26386 pd->write_cset(2, lvl * pdLEVEL + poLEVEL + 0);
26387 changed = true;
26388 }
26389 if (pd->check_cset(3, lvl * pdLEVEL + poLEVEL + 1))
26390 {
26391 pd->write_cset(3, lvl * pdLEVEL + poLEVEL + 1);
26392 changed = true;
26393 }
26394 if (pd->check_cset(4, lvl * pdLEVEL + poLEVEL + 2))
26395 {
26396 pd->write_cset(4, lvl * pdLEVEL + poLEVEL + 2);
26397 changed = true;
26398 }
26399 //Write CSet 9
26400 if (pd->check_cset(9, lvl * pdLEVEL + poLEVEL + 3))
26401 {
26402 pd->write_cset(9, lvl * pdLEVEL + poLEVEL + 3);
26403 changed = true;
26404 }
26405 //Write 1, 5, 7, 8
26406 if (pd->check_cset(1, lvl * pdLEVEL + poNEWCSETS + 0))
26407 {
26408 pd->write_cset(1, lvl * pdLEVEL + poNEWCSETS + 0);
26409 changed = true;
26410 }
26411 if (pd->check_cset(5, lvl * pdLEVEL + poNEWCSETS + 1))
26412 {
26413 pd->write_cset(5, lvl * pdLEVEL + poNEWCSETS + 1);
26414 changed = true;
26415 }
26416 if (pd->check_cset(7, lvl * pdLEVEL + poNEWCSETS + 2))
26417 {
26418 pd->write_cset(7, lvl * pdLEVEL + poNEWCSETS + 2);
26419 changed = true;
26420 }
26421 if (pd->check_cset(8, lvl * pdLEVEL + poNEWCSETS + 3))
26422 {
26423 pd->write_cset(8, lvl * pdLEVEL + poNEWCSETS + 3);
26424 changed = true;
26425 }
26426
26427 if (changed && DMaps[currdmap].color == lvl)
26428 {
26429 loadlvlpal(lvl);
26430 currcset = lvl;
26431 if (darkroom && !get_qr(qr_NEW_DARKROOM))
26432 {
26433 if (get_qr(qr_FADE))
26434 {
26435 interpolatedfade();
26436 }
26437 else
26438 {
26439 loadfadepal((DMaps[currdmap].color) * pdLEVEL + poFADE3);
26440 }
26441 }
26442 }
26443 }
26444 return;
26445 }
26446
26447 void FFScript::do_paldata_write_levelcset()
26448 {
26449 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->WriteLevelCSet()"))
26450 {
26451 int32_t lvl = get_register(sarg1) / 10000;
26452 int32_t cs = get_register(sarg2) / 10000;
26453
26454 bool changed = false;
26455
26456 switch (cs)
26457 {
26458 case 1:
26459 if (pd->check_cset(1, lvl * pdLEVEL + poNEWCSETS + 0))
26460 {
26461 pd->write_cset(1, lvl * pdLEVEL + poNEWCSETS + 0);
26462 changed = true;
26463 }
26464 break;
26465 case 2:
26466 if (pd->check_cset(2, lvl * pdLEVEL + poLEVEL + 0))
26467 {
26468 pd->write_cset(2, lvl * pdLEVEL + poLEVEL + 0);
26469 changed = true;
26470 }
26471 break;
26472 case 3:
26473 if (pd->check_cset(3, lvl * pdLEVEL + poLEVEL + 1))
26474 {
26475 pd->write_cset(3, lvl * pdLEVEL + poLEVEL + 1);
26476 changed = true;
26477 }
26478 break;
26479 case 4:
26480 if (pd->check_cset(4, lvl * pdLEVEL + poLEVEL + 2))
26481 {
26482 pd->write_cset(4, lvl * pdLEVEL + poLEVEL + 2);
26483 changed = true;
26484 }
26485 break;
26486 case 5:
26487 if (pd->check_cset(5, lvl * pdLEVEL + poNEWCSETS + 1))
26488 {
26489 pd->write_cset(5, lvl * pdLEVEL + poNEWCSETS + 1);
26490 changed = true;
26491 }
26492 break;
26493 case 7:
26494 if (pd->check_cset(7, lvl * pdLEVEL + poNEWCSETS + 2))
26495 {
26496 pd->write_cset(7, lvl * pdLEVEL + poNEWCSETS + 2);
26497 changed = true;
26498 }
26499 break;
26500 case 8:
26501 if (pd->check_cset(8, lvl * pdLEVEL + poNEWCSETS + 3))
26502 {
26503 pd->write_cset(8, lvl * pdLEVEL + poNEWCSETS + 3);
26504 changed = true;
26505 }
26506 break;
26507 case 9:
26508 if (pd->check_cset(9, lvl * pdLEVEL + poLEVEL + 3))
26509 {
26510 pd->write_cset(9, lvl * pdLEVEL + poLEVEL + 3);
26511 changed = true;
26512 }
26513 break;
26514 default:
26515 Z_scripterrlog("Invalid CSet (%d) passed to 'paldata->WriteLevelCSet()'. Level palettes can use CSets 1, 2, 3, 4, 5, 7, 8, 9.\n");
26516 return;
26517 }
26518
26519 if (changed && DMaps[currdmap].color == lvl)
26520 {
26521 loadlvlpal(lvl);
26522 if (darkroom && !get_qr(qr_NEW_DARKROOM))
26523 {
26524 if (get_qr(qr_FADE))
26525 {
26526 interpolatedfade();
26527 }
26528 else
26529 {
26530 loadfadepal((DMaps[currdmap].color) * pdLEVEL + poFADE3);
26531 }
26532 }
26533 currcset = lvl;
26534 }
26535 }
26536 }
26537
26538 void FFScript::do_paldata_write_sprite()
26539 {
26540 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->WriteSpritePalette()"))
26541 {
26542 int32_t page = get_register(sarg1) / 10000;
26543
26544 int32_t pageoffset = 0;
26545 switch (page)
26546 {
26547 case 0: pageoffset += 0; break;
26548 case 1: pageoffset += 15; break;
26549 default:
26550 Z_scripterrlog("Invalid page (%d) passed to paldata->WriteSpritePalette(). Valid pages are 0 or 1. Aborting.\n", page);
26551 return;
26552 }
26553 bool changed6 = false;
26554 bool changed14 = false;
26555 for (int32_t q = 0; q < 15; ++q)
26556 {
26557 if (pd->check_cset(q, poSPRITE255 + pageoffset + q))
26558 {
26559 pd->write_cset(q, poSPRITE255 + pageoffset + q);
26560 if (pageoffset + q == currspal6)
26561 {
26562 changed6 = true;
26563 }
26564 if (pageoffset + q == currspal14)
26565 {
26566 changed14 = true;
26567 }
26568 }
26569 }
26570
26571 //If either sprite palette has been changed, update the main palette
26572 if (changed6 || changed14)
26573 {
26574 if (changed6)
26575 {
26576 loadpalset(6, poSPRITE255 + currspal6, false);
26577 }
26578 if (changed14)
26579 {
26580 loadpalset(14, poSPRITE255 + currspal14, false);
26581 }
26582
26583 if (isMonochrome()) {
26584 if (lastMonoPreset) {
26585 restoreMonoPreset();
26586 }
26587 else {
26588 setMonochrome(false);
26589 setMonochrome(true);
26590 }
26591 }
26592
26593 if (isUserTinted()) {
26594 restoreTint();
26595 }
26596 }
26597 }
26598 return;
26599 }
26600
26601 void FFScript::do_paldata_write_spritecset()
26602 {
26603 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->WriteSpritePalette()"))
26604 {
26605 int32_t page = get_register(sarg1) / 10000;
26606 int32_t cs = get_register(sarg2) / 10000;
26607
26608 int32_t pageoffset = 0;
26609 switch (page)
26610 {
26611 case 0: pageoffset += 0; break;
26612 case 1: pageoffset += 15; break;
26613 default:
26614 Z_scripterrlog("Invalid page (%d) passed to paldata->WriteSpriteCSet(). Valid pages are 0 or 1. Aborting.\n", page);
26615 return;
26616 }
26617 bool changed6 = false;
26618 bool changed14 = false;
26619 if (unsigned(cs) > 15)
26620 {
26621 Z_scripterrlog("Invalid CSet (%d) passed to paldata->WriteSpriteCSet(). Valid CSets are 0-15. Aborting.\n", cs);
26622 return;
26623 }
26624 if (pd->check_cset(cs, poSPRITE255 + pageoffset + cs))
26625 {
26626 pd->write_cset(cs, poSPRITE255 + pageoffset + cs);
26627 if (pageoffset + cs == currspal6)
26628 {
26629 changed6 = true;
26630 }
26631 if (pageoffset + cs == currspal14)
26632 {
26633 changed14 = true;
26634 }
26635 }
26636
26637 //If either sprite palette has been changed, update the main palette
26638 if (changed6 || changed14)
26639 {
26640 if (changed6)
26641 {
26642 loadpalset(6, poSPRITE255 + currspal6, false);
26643 }
26644 if (changed14)
26645 {
26646 loadpalset(14, poSPRITE255 + currspal14, false);
26647 }
26648
26649 if (isMonochrome()) {
26650 if (lastMonoPreset) {
26651 restoreMonoPreset();
26652 }
26653 else {
26654 setMonochrome(false);
26655 setMonochrome(true);
26656 }
26657 }
26658
26659 if (isUserTinted()) {
26660 restoreTint();
26661 }
26662 }
26663 }
26664 return;
26665 }
26666
26667 void FFScript::do_paldata_write_main()
26668 {
26669 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->WriteMainPalette()"))
26670 {
26671 bool changed = false;
26672 for (int32_t q = 0; q <= 15; ++q)
26673 {
26674 if (pd->check_cset_main(q))
26675 {
26676 pd->write_cset_main(q);
26677 changed = true;
26678 }
26679 }
26680
26681 if (changed)
26682 {
26683 refreshpal = true;
26684 }
26685 }
26686 return;
26687 }
26688
26689 void FFScript::do_paldata_write_maincset()
26690 {
26691 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->WriteMainCSet()"))
26692 {
26693 int32_t cs = get_register(sarg1) / 10000;
26694
26695 bool changed = false;
26696
26697 if (unsigned(cs) < 16)
26698 {
26699 if (pd->check_cset_main(cs))
26700 {
26701 pd->write_cset_main(cs);
26702 changed = true;
26703 }
26704 }
26705 else
26706 {
26707 Z_scripterrlog("Invalid CSet (%d) passed to 'paldata->WriteMainCSet()'. Valid csets are 0-15. Aborting.\n");
26708 return;
26709 }
26710
26711 if (changed)
26712 {
26713 refreshpal = true;
26714 }
26715 }
26716 }
26717
26718 void FFScript::do_paldata_write_cycle()
26719 {
26720 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->WriteCyclePalette()"))
26721 {
26722 int32_t lvl = get_register(sarg1) / 10000;
26723 for (int32_t q = 4; q <= 12; ++q)
26724 {
26725 if (pd->check_cset(q, lvl * pdLEVEL + poLEVEL + q))
26726 {
26727 pd->write_cset(q, lvl * pdLEVEL + poLEVEL + q);
26728 }
26729 }
26730 }
26731 return;
26732 }
26733
26734 void FFScript::do_paldata_write_cyclecset()
26735 {
26736 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->WriteCycleCSet()"))
26737 {
26738 int32_t lvl = get_register(sarg1) / 10000;
26739 int32_t cs = get_register(sarg2) / 10000;
26740
26741 bool changed = false;
26742
26743 switch (cs)
26744 {
26745 case 4:
26746 case 5:
26747 case 6:
26748 case 7:
26749 case 8:
26750 case 9:
26751 case 10:
26752 case 11:
26753 case 12:
26754 if (pd->check_cset(cs, lvl * pdLEVEL + poLEVEL + cs))
26755 {
26756 pd->write_cset(cs, lvl * pdLEVEL + poLEVEL + cs);
26757 changed = true;
26758 }
26759 break;
26760 default:
26761 Z_scripterrlog("Invalid CSet (%d) passed to 'paldata->WriteCycleCSet()'. Cycle palettes use CSets 4-12.\n");
26762 return;
26763 }
26764
26765 if (changed && DMaps[currdmap].color == lvl)
26766 {
26767 loadlvlpal(lvl);
26768 currcset = lvl;
26769 }
26770 }
26771 }
26772
26773 void FFScript::do_paldata_colorvalid()
26774 {
26775 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->ColorValid()"))
26776 {
26777 int32_t ind = get_register(sarg1) / 10000;
26778 if (unsigned(ind) >= PALDATA_NUM_COLORS)
26779 {
26780 Z_scripterrlog("Invalid color index (%d) passed to paldata->ColorValid(). Valid indices are 0-255.\n", ind);
26781 set_register(sarg1, 0);
26782 return;
26783 }
26784
26785 if (get_bit(pd->colors_used, ind))
26786 {
26787 set_register(sarg1, 10000);
26788 }
26789 else
26790 {
26791 set_register(sarg1, 0);
26792 }
26793 }
26794 }
26795
26796 void FFScript::do_paldata_clearcolor()
26797 {
26798 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->SetColor()"))
26799 {
26800 int32_t ind = get_register(sarg1) / 10000;
26801 if (unsigned(ind) >= PALDATA_NUM_COLORS)
26802 {
26803 Z_scripterrlog("Invalid color index (%d) passed to paldata->ClearColor(). Valid indices are 0-255. Aborting.\n", ind);
26804 return;
26805 }
26806 set_bit(pd->colors_used, ind, false);
26807 }
26808 }
26809
26810 void FFScript::do_paldata_clearcset()
26811 {
26812 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->ClearCSet()"))
26813 {
26814 int32_t cs = get_register(sarg1) / 10000;
26815 if (unsigned(cs) > 15)
26816 {
26817 Z_scripterrlog("Invalid cset (%d) passed to paldata->ClearCSet(). Valid csets are 0-15. Aborting.\n", cs);
26818 return;
26819 }
26820 for (int32_t q = 0; q < 16; ++q)
26821 {
26822 set_bit(pd->colors_used, CSET(cs) + q, false);
26823 }
26824 }
26825 }
26826
26827 int32_t FFScript::do_paldata_getrgb(int32_t v)
26828 {
26829 const char* fname = "";
26830 switch (v)
26831 {
26832 case 0: fname = "paldata->R[]"; break;
26833 case 1: fname = "paldata->G[]"; break;
26834 case 2: fname = "paldata->B[]"; break;
26835 }
26836 if (user_paldata* pd = checkPalData(ri->paldataref, fname))
26837 {
26838 int32_t ind = ri->d[rINDEX] / 10000;
26839 if (unsigned(ind) >= PALDATA_NUM_COLORS)
26840 {
26841 Z_scripterrlog("Invalid color index (%d) passed to %s. Valid indices are 0-255.\n", ind, fname);
26842 return -10000;
26843 }
26844 if (!get_bit(pd->colors_used, ind))
26845 {
26846 Z_scripterrlog("%s tried to access unused color %d.\n", fname, ind);
26847 return -10000;
26848 }
26849 switch (v)
26850 {
26851 case 0:
26852 return pd->colors[ind].r * 10000;
26853 case 1:
26854 return pd->colors[ind].g * 10000;
26855 case 2:
26856 return pd->colors[ind].b * 10000;
26857 }
26858 }
26859 return -10000;
26860 }
26861
26862 void FFScript::do_paldata_setrgb(int32_t v, int32_t val)
26863 {
26864 const char* fname = "";
26865 switch (v)
26866 {
26867 case 0: fname = "paldata->R[]"; break;
26868 case 1: fname = "paldata->G[]"; break;
26869 case 2: fname = "paldata->B[]"; break;
26870 }
26871 if (user_paldata* pd = checkPalData(ri->paldataref, fname))
26872 {
26873 int32_t ind = ri->d[rINDEX] / 10000;
26874 if (unsigned(ind) >= PALDATA_NUM_COLORS)
26875 {
26876 Z_scripterrlog("Invalid color index (%d) passed to %s. Valid indices are 0-255. Aborting.\n", ind, fname);
26877 return;
26878 }
26879 if (unsigned(val) > 63)
26880 {
26881 Z_scripterrlog("RGB value(%d) passed to %s is out of range. RGB values range from 0 - 63.\n", val, fname);
26882 val = vbound(val, 0, 63);
26883 }
26884 if (!get_bit(pd->colors_used, ind))
26885 {
26886 Z_scripterrlog("%s tried to access unused color %d.\n", fname, ind);
26887 return;
26888 }
26889 switch (v)
26890 {
26891 case 0:
26892 pd->colors[ind].r = val;
26893 break;
26894 case 1:
26895 pd->colors[ind].g = val;
26896 break;
26897 case 2:
26898 pd->colors[ind].b = val;
26899 break;
26900 }
26901 }
26902 }
26903
26904 void FFScript::do_paldata_mix()
26905 {
26906 int32_t ref = SH::read_stack(ri->sp + 4);
26907 if (user_paldata* pd = checkPalData(ref, "paldata->Mix()"))
26908 {
26909 int32_t ref1 = SH::read_stack(ri->sp + 3);
26910 int32_t ref2 = SH::read_stack(ri->sp + 2);
26911 double percent = SH::read_stack(ri->sp + 1)/10000.0;
26912 int32_t color_space = SH::read_stack(ri->sp + 0)/10000;
26913 if (user_paldata* pd_start = checkPalData(ref1, "paldata->Mix()"))
26914 {
26915 if (user_paldata* pd_end = checkPalData(ref2, "paldata->Mix()"))
26916 {
26917 pd->mix(pd_start, pd_end, percent, color_space);
26918 }
26919 }
26920 }
26921 }
26922
26923 void FFScript::do_paldata_mixcset()
26924 {
26925 int32_t ref = SH::read_stack(ri->sp + 5);
26926 if (user_paldata* pd = checkPalData(ref, "paldata->MixCSet()"))
26927 {
26928 int32_t ref1 = SH::read_stack(ri->sp + 4);
26929 int32_t ref2 = SH::read_stack(ri->sp + 3);
26930 int32_t cset = SH::read_stack(ri->sp + 2) / 10000;
26931 double percent = SH::read_stack(ri->sp + 1) / 10000.0;
26932 int32_t color_space = SH::read_stack(ri->sp + 0) / 10000;
26933 if (user_paldata* pd_start = checkPalData(ref1, "paldata->MixCSet()"))
26934 {
26935 if (user_paldata* pd_end = checkPalData(ref2, "paldata->MixCSet()"))
26936 {
26937 if (unsigned(cset) > 15)
26938 {
26939 Z_scripterrlog("CSet passed to 'paldata->MixCSet()' out of range. Valid CSets are 0-15\n");
26940 return;
26941 }
26942 pd->mix(pd_start, pd_end, percent, color_space, CSET(cset), CSET(cset) + 16);
26943 }
26944 }
26945 }
26946 }
26947
26948 void FFScript::do_paldata_copy()
26949 {
26950 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->Copy()"))
26951 {
26952 int32_t ref_dest = get_register(sarg1);
26953 if (user_paldata* pd_dest = checkPalData(ref_dest, "paldata->Copy()"))
26954 {
26955 for (int32_t q = 0; q < PALDATA_NUM_COLORS; ++q)
26956 {
26957 pd_dest->colors[q] = pd->colors[q];
26958 }
26959 for (int32_t q = 0; q < PALDATA_BITSTREAM_SIZE; ++q)
26960 {
26961 pd_dest->colors_used[q] = pd->colors_used[q];
26962 }
26963 }
26964 }
26965 }
26966
26967 void FFScript::do_paldata_copycset()
26968 {
26969 if (user_paldata* pd = checkPalData(ri->paldataref, "paldata->CopyCSet()"))
26970 {
26971 int32_t ref_dest = SH::read_stack(ri->sp + 2);
26972 int32_t cs = SH::read_stack(ri->sp + 1) / 10000;
26973 int32_t cs_dest = SH::read_stack(ri->sp + 0) / 10000;
26974 if (user_paldata* pd_dest = checkPalData(ref_dest, "paldata->CopyCSet()"))
26975 {
26976 if (unsigned(cs) > 15)
26977 {
26978 Z_scripterrlog("Invalid CSet (%d) passed to paldata->CopyCSet(). Valid CSets are 0-15. Aborting.\n", cs);
26979 return;
26980 }
26981 for (int32_t q = 0; q < 16; ++q)
26982 {
26983 pd_dest->colors[CSET(cs_dest) + q] = pd->colors[CSET(cs) + q];
26984 set_bit(pd_dest->colors_used, CSET(cs_dest) + q, bool(get_bit(pd->colors_used, CSET(cs) + q)));
26985 }
26986 }
26987 }
26988 }
26989
26990 //Loads a cset to paldata from memory
26991 void user_paldata::load_cset(int32_t cset, int32_t dataset)
26992 {
26993 byte* si = colordata + CSET(dataset) * 3;
26994 for (int32_t q = 0; q < 16; ++q)
26995 {
26996 int32_t ind = CSET(cset) + q;
26997 colors[ind].r = si[0];
26998 colors[ind].g = si[1];
26999 colors[ind].b = si[2];
27000 set_bit(colors_used, ind, true);
27001 si += 3;
27002 }
27003 }
27004
27005 //Loads a cset to paldata from the main palette
27006 void user_paldata::load_cset_main(int32_t cset)
27007 {
27008 for (int32_t q = 0; q < 16; ++q)
27009 {
27010 int32_t ind = CSET(cset) + q;
27011 colors[ind].r = RAMpal[ind].r;
27012 colors[ind].g = RAMpal[ind].g;
27013 colors[ind].b = RAMpal[ind].b;
27014 set_bit(colors_used, ind, true);
27015 }
27016 }
27017
27018 //Writes to a memory cset from paldata
27019 void user_paldata::write_cset(int32_t cset, int32_t dataset)
27020 {
27021 byte* si = colordata + CSET(dataset) * 3;
27022 for (int32_t q = 0; q < 16; ++q)
27023 {
27024 int32_t ind = CSET(cset) + q;
27025 if (get_bit(colors_used, ind))
27026 {
27027 si[0] = colors[ind].r;
27028 si[1] = colors[ind].g;
27029 si[2] = colors[ind].b;
27030 }
27031 si += 3;
27032 }
27033 }
27034
27035 //Writes to a main palette cset from paldata
27036 void user_paldata::write_cset_main(int32_t cset)
27037 {
27038 for (int32_t q = 0; q < 16; ++q)
27039 {
27040 int32_t ind = CSET(cset) + q;
27041 if (get_bit(colors_used, ind))
27042 {
27043 RAMpal[ind] = colors[ind];
27044 }
27045 }
27046 }
27047
27048
27049 //Checks a memory cset from
27050
27051
27052
27053
27054 bool user_paldata::check_cset(int32_t cset, int32_t dataset)
27055 {
27056 byte* si = colordata + CSET(dataset) * 3;
27057 for (int32_t q = 0; q < 16; ++q)
27058 {
27059 int32_t ind = CSET(cset) + q;
27060 if (get_bit(colors_used, ind))
27061 {
27062 if (si[0] != colors[ind].r)
27063 return true;
27064 if (si[1] != colors[ind].g)
27065 return true;
27066 if (si[2] != colors[ind].b)
27067 return true;
27068 }
27069 si += 3;
27070 }
27071 return false;
27072 }
27073
27074 //Checks a memory cset from the main palette
27075 bool user_paldata::check_cset_main(int32_t cset)
27076 {
27077 for (int32_t q = 0; q < 16; ++q)
27078 {
27079 int32_t ind = CSET(cset) + q;
27080 if (get_bit(colors_used, ind))
27081 {
27082 if (RAMpal[ind].r != colors[ind].r)
27083 return true;
27084 if (RAMpal[ind].g != colors[ind].g)
27085 return true;
27086 if (RAMpal[ind].b != colors[ind].b)
27087 return true;
27088 }
27089 }
27090 return false;
27091 }
27092
27093 //Mixes a color between two paldatas
27094 RGB user_paldata::mix_color(RGB start, RGB end, double percent, int32_t color_space)
27095 {
27096 int32_t direction = 0;
27097 switch (color_space)
27098 {
27099 case CSPACE_RGB:
27100 return _RGB(byte(vbound(double(zc::math::Lerp(start.r, end.r, percent)), 0.0, 63.0)),
27101 byte(vbound(double(zc::math::Lerp(start.g, end.g, percent)), 0.0, 63.0)),
27102 byte(vbound(double(zc::math::Lerp(start.b, end.b, percent)), 0.0, 63.0)));
27103 case CSPACE_CMYK:
27104 {
27105 double convert_start[4];
27106 double convert_end[4];
27107 double convert_result[4];
27108 RGBTo(start, convert_start, color_space);
27109 RGBTo(end, convert_end, color_space);
27110 convert_result[0] = zc::math::Lerp(convert_start[0], convert_end[0], percent);
27111 convert_result[1] = zc::math::Lerp(convert_start[1], convert_end[1], percent);
27112 convert_result[2] = zc::math::Lerp(convert_start[2], convert_end[2], percent);
27113 convert_result[3] = zc::math::Lerp(convert_start[3], convert_end[3], percent);
27114 return RGBFrom(convert_result, color_space);
27115 }
27116 case CSPACE_HSV_CW:
27117 if (color_space == CSPACE_HSV_CW)
27118 direction = 1;
27119 [[fallthrough]];
27120 case CSPACE_HSV_CCW:
27121 if (color_space == CSPACE_HSV_CCW)
27122 direction = -1;
27123 [[fallthrough]];
27124 case CSPACE_HSV:
27125 {
27126 double convert_start[3];
27127 double convert_end[3];
27128 double convert_result[3];
27129 RGBTo(start, convert_start, color_space);
27130 RGBTo(end, convert_end, color_space);
27131 convert_result[0] = WrapLerp(convert_start[0], convert_end[0], percent, 0.0, 1.0, direction);
27132 convert_result[1] = zc::math::Lerp(convert_start[1], convert_end[1], percent);
27133 convert_result[2] = zc::math::Lerp(convert_start[2], convert_end[2], percent);
27134 return RGBFrom(convert_result, color_space);
27135 }
27136 case CSPACE_HSL_CW:
27137 if (color_space == CSPACE_HSL_CW)
27138 direction = 1;
27139 [[fallthrough]];
27140 case CSPACE_HSL_CCW:
27141 if (color_space == CSPACE_HSL_CCW)
27142 direction = -1;
27143 [[fallthrough]];
27144 case CSPACE_HSL:
27145 {
27146 double convert_start[3];
27147 double convert_end[3];
27148 double convert_result[3];
27149 RGBTo(start, convert_start, color_space);
27150 RGBTo(end, convert_end, color_space);
27151 convert_result[0] = WrapLerp(convert_start[0], convert_end[0], percent, 0.0, 1.0, direction);
27152 convert_result[1] = zc::math::Lerp(convert_start[1], convert_end[1], percent);
27153 convert_result[2] = zc::math::Lerp(convert_start[2], convert_end[2], percent);
27154 return RGBFrom(convert_result, color_space);
27155 }
27156 case CSPACE_LAB:
27157 {
27158 double convert_start[3];
27159 double convert_end[3];
27160 double convert_result[3];
27161 RGBTo(start, convert_start, color_space);
27162 RGBTo(end, convert_end, color_space);
27163 convert_result[0] = zc::math::Lerp(convert_start[0], convert_end[0], percent);
27164 convert_result[1] = zc::math::Lerp(convert_start[1], convert_end[1], percent);
27165 convert_result[2] = zc::math::Lerp(convert_start[2], convert_end[2], percent);
27166 return RGBFrom(convert_result, color_space);
27167 }
27168 case CSPACE_LCH_CW:
27169 if (color_space == CSPACE_LCH_CW)
27170 direction = 1;
27171 [[fallthrough]];
27172 case CSPACE_LCH_CCW:
27173 if (color_space == CSPACE_LCH_CCW)
27174 direction = -1;
27175 [[fallthrough]];
27176 case CSPACE_LCH:
27177 {
27178 double convert_start[3];
27179 double convert_end[3];
27180 double convert_result[3];
27181 RGBTo(start, convert_start, color_space);
27182 RGBTo(end, convert_end, color_space);
27183 convert_result[0] = zc::math::Lerp(convert_start[0], convert_end[0], percent);
27184 convert_result[1] = zc::math::Lerp(convert_start[1], convert_end[1], percent);
27185 convert_result[2] = WrapLerp(convert_start[2], convert_end[2], percent, 0.0, 360.0, direction);
27186 return RGBFrom(convert_result, color_space);
27187 }
27188 }
27189 return start;
27190 }
27191
27192 void user_paldata::RGBTo(RGB c, double arr[], int32_t color_space)
27193 {
27194 //From easyrgb.com/en/math.php
27195 double r = vbound(c.r / 63.0, 0.0, 1.0);
27196 double g = vbound(c.g / 63.0, 0.0, 1.0);
27197 double b = vbound(c.b / 63.0, 0.0, 1.0);
27198 switch (color_space)
27199 {
27200 case CSPACE_CMYK:
27201 {
27202 double c = 1.0 - r;
27203 double m = 1.0 - g;
27204 double y = 1.0 - b;
27205
27206 double k = 1.0;
27207
27208 if (c < k) k = c;
27209 if (m < k) k = m;
27210 if (y < k) k = y;
27211 if (k == 1)
27212 {
27213 c = 0.0;
27214 m = 0.0;
27215 y = 0.0;
27216 }
27217 else
27218 {
27219 c = (c - k) / (1.0 - k);
27220 m = (m - k) / (1.0 - k);
27221 y = (y - k) / (1.0 - k);
27222 }
27223 arr[0] = c;
27224 arr[1] = m;
27225 arr[2] = y;
27226 arr[3] = k;
27227 break;
27228 }
27229 case CSPACE_HSV_CW:
27230 case CSPACE_HSV_CCW:
27231 case CSPACE_HSV:
27232 {
27233 double min_val = std::min(std::min(r, g), b);
27234 double max_val = std::max(std::max(r, g), b);
27235 double del_max = max_val - min_val;
27236
27237 double h = 0;
27238 double s = 0;
27239 double v = max_val;
27240
27241 if (del_max != 0) //Set chroma if not gray
27242 {
27243 s = del_max / max_val;
27244
27245 double del_r = (((max_val - r) / 6.0) + (del_max / 2.0)) / del_max;
27246 double del_g = (((max_val - g) / 6.0) + (del_max / 2.0)) / del_max;
27247 double del_b = (((max_val - b) / 6.0) + (del_max / 2.0)) / del_max;
27248
27249 if (r == max_val) h = del_b - del_g;
27250 else if (g == max_val) h = (1.0 / 3.0) + del_r - del_b;
27251 else if (b == max_val) h = (2.0 / 3.0) + del_g - del_r;
27252
27253 if (h < 0) ++h;
27254 if (h > 1) --h;
27255 }
27256
27257 arr[0] = h;
27258 arr[1] = s;
27259 arr[2] = v;
27260 break;
27261 }
27262 case CSPACE_HSL_CW:
27263 case CSPACE_HSL_CCW:
27264 case CSPACE_HSL:
27265 {
27266 double min_val = std::min(std::min(r, g), b);
27267 double max_val = std::max(std::max(r, g), b);
27268 double del_max = max_val - min_val;
27269
27270 double h = 0;
27271 double s = 0;
27272 double l = (max_val + min_val) / 2.0;
27273
27274 if (del_max != 0) //Set chroma if not gray
27275 {
27276 if (l < 0.5) s = del_max / (max_val + min_val);
27277 else s = del_max / (2 - max_val - min_val);
27278
27279 double del_r = (((max_val - r) / 6.0) + (del_max / 2.0)) / del_max;
27280 double del_g = (((max_val - g) / 6.0) + (del_max / 2.0)) / del_max;
27281 double del_b = (((max_val - b) / 6.0) + (del_max / 2.0)) / del_max;
27282
27283 if (r == max_val) h = del_b - del_g;
27284 else if (g == max_val) h = (1.0 / 3.0) + del_r - del_b;
27285 else if (b == max_val) h = (2.0 / 3.0) + del_g - del_r;
27286
27287 if (h < 0) ++h;
27288 if (h > 1) --h;
27289 }
27290
27291 arr[0] = h;
27292 arr[1] = s;
27293 arr[2] = l;
27294 break;
27295 }
27296 case CSPACE_LAB:
27297 {
27298 if (r > 0.04045) r = pow(((r + 0.055) / 1.055), 2.4);
27299 else r /= 12.92;
27300 if (g > 0.04045) g = pow(((g + 0.055) / 1.055), 2.4);
27301 else g /= 12.92;
27302 if (b > 0.04045) b = pow(((b + 0.055) / 1.055), 2.4);
27303 else b /= 12.92;
27304
27305 double x = r * 0.4124 + g * 0.3576 + b * 0.1805;
27306 double y = r * 0.2126 + g * 0.7152 + b * 0.0722;
27307 double z = r * 0.0193 + g * 0.1192 + b * 0.9505;
27308
27309 if (x > 0.008856) x = pow(x, 1.0 / 3.0);
27310 else x = (7.787 * x) + (16.0 / 116.0);
27311 if (y > 0.008856) y = pow(y, 1.0 / 3.0);
27312 else y = (7.787 * y) + (16.0 / 116.0);
27313 if (z > 0.008856) z = pow(z, 1.0 / 3.0);
27314 else z = (7.787 * z) + (16.0 / 116.0);
27315
27316 double CIEL = (116 * y) - 16;
27317 double CIEa = 500 * (x - y);
27318 double CIEb = 200 * (y - z);
27319
27320 arr[0] = CIEL;
27321 arr[1] = CIEa;
27322 arr[2] = CIEb;
27323 break;
27324 }
27325 case CSPACE_LCH_CW:
27326 case CSPACE_LCH_CCW:
27327 case CSPACE_LCH:
27328 {
27329 if (r > 0.04045) r = pow(((r + 0.055) / 1.055), 2.4);
27330 else r /= 12.92;
27331 if (g > 0.04045) g = pow(((g + 0.055) / 1.055), 2.4);
27332 else g /= 12.92;
27333 if (b > 0.04045) b = pow(((b + 0.055) / 1.055), 2.4);
27334 else b /= 12.92;
27335
27336 double x = r * 0.4124 + g * 0.3576 + b * 0.1805;
27337 double y = r * 0.2126 + g * 0.7152 + b * 0.0722;
27338 double z = r * 0.0193 + g * 0.1192 + b * 0.9505;
27339
27340 if (x > 0.008856) x = pow(x, 1.0 / 3.0);
27341 else x = (7.787 * x) + (16.0 / 116.0);
27342 if (y > 0.008856) y = pow(y, 1.0 / 3.0);
27343 else y = (7.787 * y) + (16.0 / 116.0);
27344 if (z > 0.008856) z = pow(z, 1.0 / 3.0);
27345 else z = (7.787 * z) + (16.0 / 116.0);
27346
27347 double CIEL = (116 * y) - 16;
27348 double CIEa = 500 * (x - y);
27349 double CIEb = 200 * (y - z);
27350
27351 double h = atan2(CIEb, CIEa);
27352 if (h > 0) h = (h / PI) * 180;
27353 else h = 360 - (abs(h) / PI) * 180;
27354
27355 double CIEC = sqrt(pow(CIEa, 2) + pow(CIEb, 2));
27356
27357 arr[0] = CIEL;
27358 arr[1] = CIEC;
27359 arr[2] = h;
27360 break;
27361 }
27362 }
27363
27364 }
27365
27366 RGB user_paldata::RGBFrom(double arr[], int32_t color_space)
27367 {
27368 double r = 0.0;
27369 double g = 0.0;
27370 double b = 0.0;
27371 switch (color_space)
27372 {
27373 case CSPACE_CMYK:
27374 {
27375 double c = (arr[0] * (1 - arr[3]) + arr[3]);
27376 double m = (arr[1] * (1 - arr[3]) + arr[3]);
27377 double y = (arr[2] * (1 - arr[3]) + arr[3]);
27378
27379 r = vbound((1 - c) * 63.0, 0.0, 63.0);
27380 g = vbound((1 - m) * 63.0, 0.0, 63.0);
27381 b = vbound((1 - y) * 63.0, 0.0, 63.0);
27382 return _RGB(r, g, b);
27383 break;
27384 }
27385 case CSPACE_HSV_CW:
27386 case CSPACE_HSV_CCW:
27387 case CSPACE_HSV:
27388 {
27389 double h = arr[0];
27390 double s = arr[1];
27391 double v = arr[2];
27392
27393 if (s == 0)
27394 {
27395 r = v;
27396 g = v;
27397 b = v;
27398 }
27399 else
27400 {
27401 double var_h = h * 6;
27402 if (var_h >= 6) var_h = 0;
27403 int32_t var_i = floor(var_h);
27404 double var_1 = v * (1 - s);
27405 double var_2 = v * (1 - s * (var_h - var_i));
27406 double var_3 = v * (1 - s * (1 - (var_h - var_i)));
27407
27408 switch (var_i)
27409 {
27410 case 0:
27411 r = v;
27412 g = var_3;
27413 b = var_1;
27414 break;
27415 case 1:
27416 r = var_2;
27417 g = v;
27418 b = var_1;
27419 break;
27420 case 2:
27421 r = var_1;
27422 g = v;
27423 b = var_3;
27424 break;
27425 case 3:
27426 r = var_1;
27427 g = var_2;
27428 b = v;
27429 break;
27430 case 4:
27431 r = var_3;
27432 g = var_1;
27433 b = v;
27434 break;
27435 default:
27436 r = v;
27437 g = var_1;
27438 b = var_2;
27439 }
27440 }
27441
27442 r = vbound(r * 63.0, 0.0, 63.0);
27443 g = vbound(g * 63.0, 0.0, 63.0);
27444 b = vbound(b * 63.0, 0.0, 63.0);
27445
27446 return _RGB(r, g, b);
27447 }
27448 case CSPACE_HSL_CW:
27449 case CSPACE_HSL_CCW:
27450 case CSPACE_HSL:
27451 {
27452 double h = arr[0];
27453 double s = arr[1];
27454 double l = arr[2];
27455
27456 if (s == 0)
27457 {
27458 r = l;
27459 g = l;
27460 b = l;
27461 }
27462 else
27463 {
27464 double var_1;
27465 double var_2;
27466 if (l < 0.5)var_2 = l * (1 + s);
27467 else var_2 = (l + s) - (s * l);
27468
27469 var_1 = 2 * l - var_2;
27470
27471 r = HueToRGB(var_1, var_2, h + (1.0 / 3.0));
27472 g = HueToRGB(var_1, var_2, h);
27473 b = HueToRGB(var_1, var_2, h - (1.0 / 3.0));
27474 }
27475
27476 r = vbound(r * 63.0, 0.0, 63.0);
27477 g = vbound(g * 63.0, 0.0, 63.0);
27478 b = vbound(b * 63.0, 0.0, 63.0);
27479
27480 return _RGB(r, g, b);
27481 }
27482 case CSPACE_LAB:
27483 {
27484 double CIEL = arr[0];
27485 double CIEa = arr[1];
27486 double CIEb = arr[2];
27487
27488 double var_y = (CIEL + 16) / 116.0;
27489 double var_x = CIEa / 500.0 + var_y;
27490 double var_z = var_y - CIEb / 200.0;
27491
27492 if (pow(var_x, 3) > 0.008856) var_x = pow(var_x, 3);
27493 else var_x = (var_x - 16.0 / 116.0) / 7.787;
27494 if (pow(var_y, 3) > 0.008856) var_y = pow(var_y, 3);
27495 else var_y = (var_y - 16.0 / 116.0) / 7.787;
27496 if (pow(var_z, 3) > 0.008856) var_z = pow(var_z, 3);
27497 else var_z = (var_z - 16.0 / 116.0) / 7.787;
27498
27499 r = var_x * 3.2406 + var_y * -1.5372 + var_z * -0.4986;
27500 g = var_x * -0.9689 + var_y * 1.8758 + var_z * 0.0415;
27501 b = var_x * 0.0557 + var_y * -0.2040 + var_z * 1.0570;
27502
27503 if (r > 0.0031308) r = 1.055 * pow(r, (1 / 2.4)) - 0.055;
27504 else r = 12.92 * r;
27505 if (g > 0.0031308) g = 1.055 * pow(g, (1 / 2.4)) - 0.055;
27506 else g = 12.92 * g;
27507 if (b > 0.0031308) b = 1.055 * pow(b, (1 / 2.4)) - 0.055;
27508 else b = 12.92 * b;
27509
27510 r = vbound(r * 63.0, 0.0, 63.0);
27511 g = vbound(g * 63.0, 0.0, 63.0);
27512 b = vbound(b * 63.0, 0.0, 63.0);
27513
27514 return _RGB(r, g, b);
27515 }
27516 case CSPACE_LCH_CW:
27517 case CSPACE_LCH_CCW:
27518 case CSPACE_LCH:
27519 {
27520 double CIEL = arr[0];
27521 double CIEa = cos((arr[2] * PI) / 180.0) * arr[1];
27522 double CIEb = sin((arr[2] * PI) / 180.0) * arr[1];
27523
27524 double var_y = (CIEL + 16) / 116.0;
27525 double var_x = CIEa / 500.0 + var_y;
27526 double var_z = var_y - CIEb / 200.0;
27527
27528 if (pow(var_y, 3) > 0.008856) var_y = pow(var_y, 3);
27529 else var_y = (var_y - 16.0 / 116.0) / 7.787;
27530 if (pow(var_x, 3) > 0.008856) var_x = pow(var_x, 3);
27531 else var_x = (var_x - 16.0 / 116.0) / 7.787;
27532 if (pow(var_z, 3) > 0.008856) var_z = pow(var_z, 3);
27533 else var_z = (var_z - 16.0 / 116.0) / 7.787;
27534
27535 r = var_x * 3.2406 + var_y * -1.5372 + var_z * -0.4986;
27536 g = var_x * -0.9689 + var_y * 1.8758 + var_z * 0.0415;
27537 b = var_x * 0.0557 + var_y * -0.2040 + var_z * 1.0570;
27538
27539 if (r > 0.0031308) r = 1.055 * pow(r, (1 / 2.4)) - 0.055;
27540 else r = 12.92 * r;
27541 if (g > 0.0031308) g = 1.055 * pow(g, (1 / 2.4)) - 0.055;
27542 else g = 12.92 * g;
27543 if (b > 0.0031308) b = 1.055 * pow(b, (1 / 2.4)) - 0.055;
27544 else b = 12.92 * b;
27545
27546 r = vbound(r * 63.0, 0.0, 63.0);
27547 g = vbound(g * 63.0, 0.0, 63.0);
27548 b = vbound(b * 63.0, 0.0, 63.0);
27549
27550 return _RGB(r, g, b);
27551 }
27552 }
27553 return _RGB(0, 0, 0);
27554 }
27555 double user_paldata::HueToRGB(double v1, double v2, double vH)
27556 {
27557 if (vH < 0) vH += 1;
27558 if (vH > 1) vH -= 1;
27559 if ((6 * vH) < 1) return (v1 + (v2 - v1) * 6 * vH);
27560 if ((2 * vH) < 1) return (v2);
27561 if ((3 * vH) < 2) return (v1 + (v2 - v1) * ((2.0 / 3.0) - vH) * 6);
27562 return (v1);
27563 }
27564
27565 double user_paldata::WrapLerp(double a, double b, double t, double min, double max, int32_t direction)
27566 {
27567 double dif = abs(a - b);
27568 double range = abs(max - min);
27569
27570 switch (direction)
27571 {
27572 case 0:
27573 if (dif > range * 0.5)
27574 dif = range - dif;
27575 if (a + dif == b)
27576 direction = 1;
27577 else
27578 direction = -1;
27579 break;
27580 case 1:
27581 if (b < a)
27582 dif = range - dif;
27583 break;
27584 case -1:
27585 if (b > a)
27586 dif = range - dif;
27587 break;
27588 }
27589
27590 double ret = zc::math::Lerp(a, a + dif * direction, t);
27591
27592 if (ret <= min)
27593 ret += range;
27594 else if (ret >= max)
27595 ret -= range;
27596 return ret;
27597 }
27598
27599 //Mixes an entire palette given two paldatas
27600 void user_paldata::mix(user_paldata *pal_start, user_paldata *pal_end, double percent, int32_t color_space, int32_t start_color, int32_t end_color)
27601 {
27602 for (int32_t q = start_color; q < end_color; ++q)
27603 {
27604 if (get_bit(pal_start->colors_used, q) && get_bit(pal_end->colors_used, q)) {
27605 RGB start = pal_start->colors[q];
27606 RGB end = pal_end->colors[q];
27607 colors[q] = mix_color(start, end, percent, color_space);
27608 }
27609 }
27610 }
27611
27612 void item_display_name(const bool setter)
27613 {
27614 int32_t ID = ri->idata;
27615 if(unsigned(ID) >= MAXITEMS)
27616 return;
27617 int32_t arrayptr = get_register(sarg1) / 10000;
27618 if(setter)
27619 {
27620 std::string str;
27621 ArrayH::getString(arrayptr, str, 255);
27622 strcpy(itemsbuf[ID].display_name, str.c_str());
27623 }
27624 else
27625 {
27626 if(ArrayH::setArray(arrayptr, string(itemsbuf[ID].display_name)) == SH::_Overflow)
27627 Z_scripterrlog("Array supplied to 'itemdata->GetDisplayName()' not large enough\n");
27628 }
27629 }
27630 void item_shown_name()
27631 {
27632 int32_t ID = ri->idata;
27633 if(unsigned(ID) >= MAXITEMS)
27634 return;
27635 int32_t arrayptr = get_register(sarg1) / 10000;
27636 if(ArrayH::setArray(arrayptr, itemsbuf[ID].get_name()) == SH::_Overflow)
27637 Z_scripterrlog("Array supplied to 'itemdata->GetShownName()' not large enough\n");
27638 }
27639
27640 void FFScript::do_getDMapData_dmapname(const bool v)
27641 {
27642 //int32_t ID = ri->zmsgref;
27643 int32_t ID = ri->dmapsref;
27644 int32_t arrayptr = get_register(sarg1) / 10000;
27645
27646 if(BC::checkDMapID(ID, "dmapdata->GetName()") != SH::_NoError)
27647 return;
27648
27649 if(ArrayH::setArray(arrayptr, string(DMaps[ID].name)) == SH::_Overflow)
27650 Z_scripterrlog("Array supplied to 'dmapdata->GetName()' not large enough\n");
27651 }
27652
27653 void FFScript::do_setDMapData_dmapname(const bool v)
27654 {
27655 //int32_t ID = ri->zmsgref;
27656 int32_t ID = ri->dmapsref;
27657 int32_t arrayptr = get_register(sarg1) / 10000;
27658
27659 string filename_str;
27660
27661 if(BC::checkDMapID(ID, "dmapdata->SetName()") != SH::_NoError)
27662 return;
27663
27664
27665 ArrayH::getString(arrayptr, filename_str, 22);
27666 strncpy(DMaps[ID].name, filename_str.c_str(), 21);
27667 DMaps[ID].name[20]='\0';
27668 }
27669
27670 void FFScript::do_getDMapData_dmaptitle(const bool v)
27671 {
27672 //int32_t ID = ri->zmsgref;
27673 int32_t ID = ri->dmapsref;
27674 int32_t arrayptr = get_register(sarg1) / 10000;
27675
27676 if(BC::checkDMapID(ID, "dmapdata->GetIntro()") != SH::_NoError)
27677 return;
27678
27679 if(ArrayH::setArray(arrayptr, string(DMaps[ID].title)) == SH::_Overflow)
27680 Z_scripterrlog("Array supplied to 'dmapdata->GetIntro()' not large enough\n");
27681 }
27682
27683 void FFScript::do_setDMapData_dmaptitle(const bool v)
27684 {
27685 //int32_t ID = ri->zmsgref;
27686 int32_t ID = ri->dmapsref;
27687 int32_t arrayptr = get_register(sarg1) / 10000;
27688 string filename_str;
27689
27690 if(BC::checkDMapID(ID, "dmapdata->SetTitle()") != SH::_NoError)
27691 return;
27692
27693
27694 ArrayH::getString(arrayptr, filename_str, 21);
27695 strncpy(DMaps[ID].title, filename_str.c_str(), 20);
27696 DMaps[ID].title[20]='\0';
27697 }
27698
27699 void FFScript::do_getDMapData_dmapintro(const bool v)
27700 {
27701 //int32_t ID = ri->zmsgref;
27702 int32_t ID = ri->dmapsref;
27703 int32_t arrayptr = get_register(sarg1) / 10000;
27704
27705 if(BC::checkDMapID(ID, "dmapdata->GetIntro()") != SH::_NoError)
27706 return;
27707
27708 if(ArrayH::setArray(arrayptr, string(DMaps[ID].intro)) == SH::_Overflow)
27709 Z_scripterrlog("Array supplied to 'dmapdata->GetIntro()' not large enough\n");
27710 }
27711
27712 void FFScript::do_setDMapData_dmapintro(const bool v)
27713 {
27714 //int32_t ID = ri->zmsgref;
27715 int32_t ID = ri->dmapsref;
27716 int32_t arrayptr = get_register(sarg1) / 10000;
27717 string filename_str;
27718
27719 if(BC::checkDMapID(ID, "dmapdata->SetIntro()") != SH::_NoError)
27720 return;
27721
27722
27723 ArrayH::getString(arrayptr, filename_str, 73);
27724 strncpy(DMaps[ID].intro, filename_str.c_str(), 72);
27725 DMaps[ID].intro[72]='\0';
27726 }
27727
27728 void FFScript::do_getDMapData_music(const bool v)
27729 {
27730 //int32_t ID = ri->zmsgref;
27731 int32_t ID = ri->dmapsref;
27732 int32_t arrayptr = get_register(sarg1) / 10000;
27733
27734 if(BC::checkDMapID(ID, "dmapdata->GetMusic()") != SH::_NoError)
27735 return;
27736
27737 if(ArrayH::setArray(arrayptr, string(DMaps[ID].tmusic)) == SH::_Overflow)
27738 Z_scripterrlog("Array supplied to 'dmapdata->GetMusic()' not large enough\n");
27739 }
27740
27741 void FFScript::do_setDMapData_music(const bool v)
27742 {
27743 //int32_t ID = ri->zmsgref;
27744 int32_t ID = ri->dmapsref;
27745 int32_t arrayptr = get_register(sarg1) / 10000;
27746 string filename_str;
27747
27748 if(BC::checkDMapID(ID, "dmapdata->SetMusic()") != SH::_NoError)
27749 return;
27750
27751
27752 ArrayH::getString(arrayptr, filename_str, 56);
27753 strncpy(DMaps[ID].tmusic, filename_str.c_str(), 55);
27754 DMaps[ID].tmusic[55]='\0';
27755 }
27756
27757 void FFScript::do_loadnpcdata(const bool v)
27758 {
27759 int32_t ID = SH::get_arg(sarg1, v) / 10000;
27760
27761 if ( ID < 1 || ID > (MAXGUYS-1) )
27762 {
27763 Z_scripterrlog("Invalid NPC ID passed to Game->LoadNPCData: %d\n", ID);
27764 ri->npcdataref = MAX_DWORD;
27765 }
27766
27767 else ri->npcdataref = ID;
27768 //Z_eventlog("Script loaded npcdata with ID = %ld\n", ri->idata);
27769 }
27770 void FFScript::do_loadmessagedata(const bool v)
27771 {
27772 int32_t ID = SH::get_arg(sarg1, v) / 10000;
27773
27774 if ( ID < 1 || ID > (msg_count-1) )
27775 {
27776 Z_scripterrlog("Invalid Message ID passed to Game->LoadMessageData: %d\n", ID);
27777 ri->zmsgref = MAX_DWORD;
27778 }
27779
27780 else ri->zmsgref = ID;
27781 //Z_eventlog("Script loaded npcdata with ID = %ld\n", ri->idata);
27782 }
27783 //same syntax as loadmessage data
27784 //the input is an array
27785 void FFScript::do_messagedata_setstring(const bool v)
27786 {
27787 int32_t arrayptr = get_register(sarg1) / 10000;
27788 int32_t ID = ri->zmsgref;
27789 if(BC::checkMessage(ID, "messagesata->Set()") != SH::_NoError)
27790 return;
27791
27792 ArrayH::getString(arrayptr, MsgStrings[ID].s, MSG_NEW_SIZE);
27793 }
27794 void FFScript::do_messagedata_getstring(const bool v)
27795 {
27796 int32_t ID = ri->zmsgref;
27797 int32_t arrayptr = get_register(sarg1) / 10000;
27798
27799 if(BC::checkMessage(ID, "messagedata->Get()") != SH::_NoError)
27800 return;
27801
27802 if(ArrayH::setArray(arrayptr, MsgStrings[ID].s) == SH::_Overflow)
27803 Z_scripterrlog("Array supplied to 'messagedata->Get()' not large enough\n");
27804 }
27805
27806 25412 void FFScript::do_loadcombodata(const bool v)
27807 {
27808 25412 int32_t ID = SH::get_arg(sarg1, v) / 10000;
27809
27810
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25412 times.
25412 if ( (unsigned)ID > (MAXCOMBOS-1) )
27811 {
27812 Z_scripterrlog("Invalid Combo ID passed to Game->LoadComboData: %d\n", ID);
27813 ri->combosref = 0;
27814 }
27815
27816 25412 else ri->combosref = ID;
27817 //Z_eventlog("Script loaded mapdata with ID = %ld\n", ri->idata);
27818 25412 }
27819
27820 void FFScript::do_loadmapdata(const bool v)
27821 {
27822 int32_t _map = SH::get_arg(sarg1, v) / 10000;
27823
27824 int32_t _scr = SH::get_arg(sarg2, v) / 10000;
27825 // zprint("LoadMapData Map Value: %d\n", _map);
27826 // zprint("LoadMapData Screen Value: %d\n", _scr);
27827 int32_t indx = (_map * MAPSCRS + _scr);
27828 // zprint("LoadMapData Indx Value: %d\n", indx);
27829 if ( _map < 1 || _map > (map_count-1) )
27830 {
27831 Z_scripterrlog("Invalid Map ID passed to Game->LoadMapData: %d\n", _map);
27832 ri->mapsref = 0;
27833 }
27834 else if ( (unsigned)_scr > 129 ) //0x00 to 0x81 -Z
27835 {
27836 Z_scripterrlog("Invalid Screen ID passed to Game->LoadMapData: %d\n", _scr);
27837 ri->mapsref = 0;
27838 }
27839 else ri->mapsref = indx;
27840 // zprint("LoadMapData Screen set ri->mapsref to: %d\n", ri->mapsref);
27841 //zprint("Script loaded mapdata with ID = %ld\n", ri->idata);
27842 }
27843
27844 403497 void FFScript::do_loadmapdata_tempscr(const bool v)
27845 {
27846 403497 int32_t layer = SH::get_arg(sarg1, v) / 10000;
27847
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 403497 times.
403497 if(BC::checkBounds(layer, 0, 6, "Game->LoadTempScreen()") != SH::_NoError)
27848 {
27849 ri->mapsref = 0;
27850 return;
27851 }
27852
7/8
✗ Branch 0 not taken.
✓ Branch 1 taken 89778 times.
✓ Branch 2 taken 118147 times.
✓ Branch 3 taken 102973 times.
✓ Branch 4 taken 915 times.
✓ Branch 5 taken 91682 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1 times.
403497 switch(layer)
27853 {
27854 89778 case 0: ri->mapsref = MAPSCR_TEMP0; break;
27855 118147 case 1: ri->mapsref = MAPSCR_TEMP1; break;
27856 102973 case 2: ri->mapsref = MAPSCR_TEMP2; break;
27857 915 case 3: ri->mapsref = MAPSCR_TEMP3; break;
27858 91682 case 4: ri->mapsref = MAPSCR_TEMP4; break;
27859 1 case 5: ri->mapsref = MAPSCR_TEMP5; break;
27860 1 case 6: ri->mapsref = MAPSCR_TEMP6; break;
27861 }
27862 403497 set_register(sarg1, ri->mapsref);
27863 403497 }
27864
27865 177544 void FFScript::do_loadmapdata_scrollscr(const bool v)
27866 {
27867 177544 int32_t layer = SH::get_arg(sarg1, v) / 10000;
27868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 177544 times.
177544 if(BC::checkBounds(layer, 0, 6, "Game->LoadScrollingScreen()") != SH::_NoError)
27869 {
27870 ri->mapsref = 0;
27871 return;
27872 }
27873
3/8
✗ Branch 0 not taken.
✓ Branch 1 taken 88755 times.
✓ Branch 2 taken 88755 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 34 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
177544 switch(layer)
27874 {
27875 88755 case 0: ri->mapsref = MAPSCR_SCROLL0; break;
27876 88755 case 1: ri->mapsref = MAPSCR_SCROLL1; break;
27877 case 2: ri->mapsref = MAPSCR_SCROLL2; break;
27878 case 3: ri->mapsref = MAPSCR_SCROLL3; break;
27879 34 case 4: ri->mapsref = MAPSCR_SCROLL4; break;
27880 case 5: ri->mapsref = MAPSCR_SCROLL5; break;
27881 case 6: ri->mapsref = MAPSCR_SCROLL6; break;
27882 }
27883 177544 set_register(sarg1, ri->mapsref);
27884 177544 }
27885
27886 void FFScript::do_loadshopdata(const bool v)
27887 {
27888 int32_t ID = SH::get_arg(sarg1, v) / 10000;
27889
27890 if ( (unsigned)ID > 255 )
27891 {
27892 Z_scripterrlog("Invalid Shop ID passed to Game->LoadShopData: %d\n", ID);
27893 ri->shopsref = 0;
27894 }
27895 else ri->shopsref = ID;
27896 //Z_eventlog("Script loaded npcdata with ID = %ld\n", ri->idata);
27897 }
27898
27899
27900 void FFScript::do_loadinfoshopdata(const bool v)
27901 {
27902 int32_t ID = SH::get_arg(sarg1, v) / 10000;
27903
27904 if ( (unsigned)ID > 255 )
27905 {
27906 Z_scripterrlog("Invalid Shop ID passed to Game->LoadShopData: %d\n", ID);
27907 ri->shopsref = 0;
27908 }
27909 else ri->shopsref = ID+NUMSHOPS;
27910 //Z_eventlog("Script loaded npcdata with ID = %ld\n", ri->idata);
27911 }
27912
27913 /*
27914 void FFScript::do_loadmapdata(const bool v)
27915 {
27916 int32_t ID = SH::get_arg(sarg1, v) / 10000;
27917
27918 if ( ID < 0 || ID > (map_count-1) )
27919 {
27920 Z_scripterrlog("Invalid Map ID passed to Game->LoadMapData: %d\n", ID);
27921 ri->mapsref = MAX_SIGNED_32;
27922 }
27923
27924 else ri->mapsref = ID;
27925 //Z_eventlog("Script loaded mapdata with ID = %ld\n", ri->idata);
27926 }
27927 */
27928
27929 /*
27930
27931 void FFScript::do_loadmapdata(const bool v)
27932 {
27933 int32_t ID = get_register(sarg2) / 10000;
27934
27935 if ( ID < 0 || ID > (map_count-1) )
27936 {
27937 Z_scripterrlog("Invalid Map ID passed to Game->LoadMapData: %d\n", ID);
27938 return;
27939 }
27940
27941 ri->mapsref = ID;
27942 set_register(sarg1, ri->mapsref);
27943 //Z_eventlog("Script loaded mapdata with ID = %ld\n", ri->idata);
27944 }
27945
27946 */
27947
27948 void FFScript::do_loadspritedata(const bool v)
27949 {
27950 int32_t ID = SH::get_arg(sarg1, v) / 10000;
27951
27952 if ( (unsigned)ID > (MAXWPNS-1) )
27953 {
27954 Z_scripterrlog("Invalid Sprite ID passed to Game->LoadSpriteData: %d\n", ID);
27955 ri->spritesref = 0;
27956 }
27957
27958 else ri->spritesref = ID;
27959 //Z_eventlog("Script loaded mapdata with ID = %ld\n", ri->idata);
27960 }
27961
27962
27963 void FFScript::do_loadscreendata(const bool v)
27964 {
27965 int32_t ID = SH::get_arg(sarg1, v) / 10000;
27966
27967 if ( (unsigned)ID > (MAXSCREENS-1) )
27968 {
27969 Z_scripterrlog("Invalid Map ID passed to Game->LoadScreenData: %d\n", ID);
27970 ri->screenref = 0;
27971 }
27972
27973 else ri->screenref = ID;
27974 //Z_eventlog("Script loaded mapdata with ID = %ld\n", ri->idata);
27975 }
27976
27977 void FFScript::do_loadbitmapid(const bool v)
27978 {
27979 int32_t ID = SH::get_arg(sarg1, v) / 10000;
27980 switch(ID)
27981 {
27982 case -1:
27983 case 0:
27984 case 1:
27985 case 2:
27986 case 3:
27987 case 4:
27988 case 5:
27989 case 6:
27990 ri->bitmapref = ID+10; break;
27991 default:
27992 {
27993 Z_scripterrlog("Invalid Bitmap ID passed to Game->Load BitmapID: %d\n", ID);
27994 ri->bitmapref = 0; break;
27995 }
27996 }
27997
27998 //Z_eventlog("Script loaded mapdata with ID = %ld\n", ri->idata);
27999 }
28000
28001 77262 void do_createlweapon(const bool v)
28002 {
28003 77262 const int32_t ID = SH::get_arg(sarg1, v) / 10000;
28004
28005
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77262 times.
77262 if(BC::checkWeaponID(ID, "Screen->CreateLWeapon") != SH::_NoError)
28006 return;
28007
28008
1/2
✓ Branch 0 taken 77262 times.
✗ Branch 1 not taken.
77262 if ( Lwpns.has_space() )
28009 {
28010 77262 Lwpns.add
28011 (
28012
1/2
✓ Branch 0 taken 77262 times.
✗ Branch 1 not taken.
154524 new weapon
28013 (
28014
1/2
✓ Branch 0 taken 77262 times.
✗ Branch 1 not taken.
77262 (zfix)0, /*X*/
28015
1/2
✓ Branch 0 taken 77262 times.
✗ Branch 1 not taken.
77262 (zfix)0, /*Y*/
28016
1/2
✓ Branch 0 taken 77262 times.
✗ Branch 1 not taken.
77262 (zfix)0, /*Z*/
28017 77262 ID, /*id*/
28018 0, /*type*/
28019 0, /*power*/
28020 0, /*dir*/
28021 -1, /*Parentid*/
28022
1/2
✓ Branch 0 taken 77262 times.
✗ Branch 1 not taken.
77262 Hero.getUID(), /*prntid*/
28023 false, /*isdummy*/
28024 1, /*script_gen*/
28025 1, /*islwpn*/
28026 77262 (ID==wWind?1:0) /*special*/
28027 )
28028 );
28029 77262 ri->lwpn = Lwpns.spr(Lwpns.Count() - 1)->getUID();
28030 //Lwpns.spr(Lwpns.Count() - 1)->LOADGFX(0);
28031 //Lwpns.spr(Lwpns.Count() - 1)->ScriptGenerated = 1;
28032 //Lwpns.spr(Lwpns.Count() - 1)->isLWeapon = 1;
28033 77262 weapon *w = (weapon*)Lwpns.spr(Lwpns.Count()-1); //last created
28034 //w->LOADGFX(FFCore.getDefWeaponSprite(ID)); //No.
28035 77262 w->ScriptGenerated = 1;
28036 77262 w->isLWeapon = 1;
28037
1/2
✓ Branch 0 taken 77262 times.
✗ Branch 1 not taken.
77262 if(ID == wWind) w->specialinfo = 1;
28038 77262 Z_eventlog("Script created lweapon %ld with UID = %ld\n", ID, ri->lwpn);
28039 77262 }
28040 else
28041 {
28042 //ri->lwpn = MAX_DWORD;
28043 ri->lwpn = 0; // Now NULL
28044 Z_scripterrlog("Couldn't create lweapon %ld, screen lweapon limit reached\n", ID);
28045 }
28046 77262 }
28047
28048 131917 void do_createeweapon(const bool v)
28049 {
28050 131917 const int32_t ID = SH::get_arg(sarg1, v) / 10000;
28051
28052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131917 times.
131917 if(BC::checkWeaponID(ID, "Screen->CreateEWeapon") != SH::_NoError)
28053 return;
28054
28055
1/2
✓ Branch 0 taken 131917 times.
✗ Branch 1 not taken.
131917 if ( Ewpns.has_space() )
28056 {
28057 131917 addEwpn(0, 0, 0, ID, 0, 0, 0, -1,1); //Param 9 marks it as script-generated.
28058 //Ewpns.spr(Ewpns.Count() - 1)->LOADGFX(0);
28059 //Ewpns.spr(Ewpns.Count() - 1)->ScriptGenerated = 1;
28060 //Ewpns.spr(Ewpns.Count() - 1)->isLWeapon = 0;
28061
4/6
✓ Branch 0 taken 122104 times.
✓ Branch 1 taken 9813 times.
✓ Branch 2 taken 122104 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 122104 times.
✗ Branch 5 not taken.
131917 if( ID > wEnemyWeapons || ( ID >= wScript1 && ID <= wScript10) )
28062 {
28063 131917 weapon *w = (weapon*)Ewpns.spr(Ewpns.Count()-1); //last created
28064 //w->LOADGFX(FFCore.getDefWeaponSprite(ID));
28065 131917 w->ScriptGenerated = 1;
28066 131917 w->isLWeapon = 0;
28067 131917 ri->ewpn = Ewpns.spr(Ewpns.Count() - 1)->getUID();
28068 131917 Z_eventlog("Script created eweapon %ld with UID = %ld\n", ID, ri->ewpn);
28069 131917 }
28070 else
28071 {
28072 Z_scripterrlog("Couldn't create eweapon %ld: Invalid ID/Type (%d) specified.\n", ID);
28073 return;
28074 }
28075 131917 }
28076 else
28077 {
28078 ri->ewpn = 0;
28079 Z_scripterrlog("Couldn't create eweapon %ld, screen eweapon limit reached\n", ID);
28080 }
28081 131917 }
28082
28083 21343 void do_createitem(const bool v)
28084 {
28085 21343 const int32_t ID = SH::get_arg(sarg1, v) / 10000;
28086
28087
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21343 times.
21343 if(BC::checkItemID(ID, "Screen->CreateItem") != SH::_NoError)
28088 return;
28089
28090
1/2
✓ Branch 0 taken 21343 times.
✗ Branch 1 not taken.
21343 if ( items.has_space() )
28091 {
28092 21343 additem(0, (get_qr(qr_NOITEMOFFSET) ? 1: 0), ID, ipBIGRANGE);
28093 21343 ri->itemref = items.spr(items.Count() - 1)->getUID();
28094 21343 Z_eventlog("Script created item \"%s\" with UID = %ld\n", item_string[ID], ri->itemref);
28095 21343 }
28096 else
28097 {
28098 ri->itemref = 0;
28099 Z_scripterrlog("Couldn't create item \"%s\", screen item limit reached\n", item_string[ID]);
28100 }
28101 /*
28102 if(items.Count() < 1)
28103 {
28104 ri->itemref = MAX_DWORD;
28105 Z_scripterrlog("Couldn't create item \"%s\", screen item limit reached\n", item_string[ID]);
28106 }
28107 else
28108 {
28109 ri->itemref = items.spr(items.Count() - 1)->getUID();
28110 Z_eventlog("Script created item \"%s\" with UID = %ld\n", item_string[ID], ri->itemref);
28111 }
28112 */
28113 21343 }
28114
28115 2363 void do_createnpc(const bool v)
28116 {
28117 2363 const int32_t ID = SH::get_arg(sarg1, v) / 10000;
28118
28119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2363 times.
2363 if(BC::checkGuyID(ID, "Screen->CreateNPC") != SH::_NoError)
28120 return;
28121
28122 //If we make a segmented enemy there'll be more than one sprite created
28123 2363 word numcreated = addenemy(0, 0, ID, -10);
28124
28125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2363 times.
2363 if(numcreated == 0)
28126 {
28127 //ri->guyref = MAX_DWORD;
28128 ri->guyref = 0;
28129 Z_scripterrlog("Couldn't create NPC \"%s\", screen NPC limit reached\n", guy_string[ID]);
28130 }
28131 else
28132 {
28133 2363 word index = guys.Count() - numcreated; //Get the main enemy, not a segment
28134 2363 ri->guyref = guys.spr(index)->getUID();
28135
28136
2/2
✓ Branch 0 taken 2399 times.
✓ Branch 1 taken 2363 times.
4762 for(; index<guys.Count(); index++)
28137 2399 ((enemy*)guys.spr(index))->script_spawned=true;
28138
28139 2363 Z_eventlog("Script created NPC \"%s\" with UID = %ld\n", guy_string[ID], ri->guyref);
28140 }
28141 2363 }
28142
28143 ///----------------------------------------------------------------------------------------------------//
28144 //Drawing & Sound
28145
28146 173 void do_message(const bool v)
28147 {
28148 173 const int32_t ID = SH::get_arg(sarg1, v) / 10000;
28149
28150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 173 times.
173 if(BC::checkMessage(ID, "Screen->Message") != SH::_NoError)
28151 return;
28152
28153
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 173 times.
173 if(ID == 0)
28154 {
28155 dismissmsg();
28156 msgfont = get_zc_font(font_zfont);
28157 blockpath = false;
28158 Hero.finishedmsg();
28159 }
28160 else
28161 173 donewmsg(ID);
28162 173 }
28163
28164 37258853 INLINE void set_drawing_command_args(const int32_t j, const word numargs)
28165 {
28166
2/2
✓ Branch 0 taken 293896974 times.
✓ Branch 1 taken 37258853 times.
331155827 for(int32_t k = 1; k <= numargs; k++)
28167 293896974 script_drawing_commands[j][k] = SH::read_stack(ri->sp + (numargs - k));
28168 37258853 }
28169
28170 648786 INLINE void set_user_bitmap_command_args(const int32_t j, const word numargs)
28171 {
28172 //ri->bitmapref = SH::read_stack(ri->sp+numargs);
28173 //zprint("Current drawing bitmap ref is: %d\n", ri->bitmapref );
28174
2/2
✓ Branch 0 taken 6987552 times.
✓ Branch 1 taken 648786 times.
7636338 for(int32_t k = 1; k <= numargs; k++)
28175 6987552 script_drawing_commands[j][k] = SH::read_stack(ri->sp + (numargs - k));
28176 648786 }
28177
28178 37907639 void do_drawing_command(const int32_t script_command)
28179 {
28180 37907639 int32_t j = script_drawing_commands.GetNext();
28181
28182
1/2
✓ Branch 0 taken 37907639 times.
✗ Branch 1 not taken.
37907639 if(j == -1) //out of drawing command space
28183 {
28184 Z_scripterrlog("Max draw primitive limit reached\n");
28185 return;
28186 }
28187
28188 37907639 script_drawing_commands[j][0] = script_command;
28189 37907639 script_drawing_commands[j][18] = zscriptDrawingRenderTarget->GetCurrentRenderTarget(); // no fixed bs.
28190
28191
36/76
✓ Branch 0 taken 2198272 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1056651 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1850 times.
✓ Branch 5 taken 937398 times.
✓ Branch 6 taken 383247 times.
✓ Branch 7 taken 825002 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1716768 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 4737314 times.
✓ Branch 12 taken 17997642 times.
✓ Branch 13 taken 936091 times.
✓ Branch 14 taken 94003 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 9270 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 802244 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 49303 times.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✓ Branch 23 taken 1240874 times.
✓ Branch 24 taken 144648 times.
✓ Branch 25 taken 7806 times.
✗ Branch 26 not taken.
✓ Branch 27 taken 18927 times.
✓ Branch 28 taken 2600 times.
✓ Branch 29 taken 26528 times.
✗ Branch 30 not taken.
✓ Branch 31 taken 1480 times.
✗ Branch 32 not taken.
✓ Branch 33 taken 502 times.
✓ Branch 34 taken 144 times.
✗ Branch 35 not taken.
✓ Branch 36 taken 80910 times.
✗ Branch 37 not taken.
✓ Branch 38 taken 821 times.
✗ Branch 39 not taken.
✓ Branch 40 taken 162686 times.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✓ Branch 46 taken 1152 times.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✗ Branch 49 not taken.
✗ Branch 50 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 53 not taken.
✗ Branch 54 not taken.
✓ Branch 55 taken 2048 times.
✗ Branch 56 not taken.
✓ Branch 57 taken 6363 times.
✗ Branch 58 not taken.
✗ Branch 59 not taken.
✗ Branch 60 not taken.
✗ Branch 61 not taken.
✗ Branch 62 not taken.
✗ Branch 63 not taken.
✓ Branch 64 taken 4128276 times.
✗ Branch 65 not taken.
✗ Branch 66 not taken.
✓ Branch 67 taken 59173 times.
✓ Branch 68 taken 784 times.
✗ Branch 69 not taken.
✗ Branch 70 not taken.
✓ Branch 71 taken 45504 times.
✗ Branch 72 not taken.
✓ Branch 73 taken 229546 times.
✓ Branch 74 taken 906 times.
✓ Branch 75 taken 906 times.
37907639 switch(script_command)
28192 {
28193 case RECTR:
28194 2198272 set_drawing_command_args(j, 12);
28195 2198272 break;
28196
28197 case FRAMER:
28198 set_drawing_command_args(j, 9);
28199 break;
28200
28201 case CIRCLER:
28202 1056651 set_drawing_command_args(j, 11);
28203 1056651 break;
28204
28205 case ARCR:
28206 set_drawing_command_args(j, 14);
28207 break;
28208
28209 case ELLIPSER:
28210 1850 set_drawing_command_args(j, 12);
28211 1850 break;
28212
28213 case LINER:
28214 937398 set_drawing_command_args(j, 11);
28215 937398 break;
28216
28217 case PUTPIXELR:
28218 383247 set_drawing_command_args(j, 8);
28219 383247 break;
28220
28221 case PIXELARRAYR:
28222 {
28223 set_drawing_command_args(j, 5);
28224 std::vector<int32_t> *v = script_drawing_commands.GetVector();
28225 //for ( int32_t q = 0; q < 6; q++ )
28226 //{
28227 // zprint("PIXELARRAY script_drawing_commands[j][%d] is %d\n", q, script_drawing_commands[j][q]);
28228 //}
28229 int32_t arrayptr = script_drawing_commands[j][2]/10000;
28230 if ( !arrayptr ) //Don't crash because of vector size.
28231 {
28232 Z_scripterrlog("Invalid array pointer %d passed to Screen->PutPixels(). Aborting.", arrayptr);
28233 break;
28234 }
28235 //zprint("Pixelarray array pointer is: %d\n", arrayptr);
28236 int32_t sz = ArrayH::getSize(arrayptr);
28237 //ArrayH::getSize(script_drawing_commands[j][2]/10000);
28238 //zprint("Pixelarray size is: %d\n", sz);
28239 v->resize(sz, 0);
28240 int32_t* pos = &v->at(0);
28241
28242 ArrayH::getValues(script_drawing_commands[j][2] / 10000, pos, sz);
28243 script_drawing_commands[j].SetVector(v);
28244 break;
28245 }
28246
28247 case TILEARRAYR:
28248 {
28249 set_drawing_command_args(j, 2);
28250 std::vector<int32_t> *v = script_drawing_commands.GetVector();
28251 //for ( int32_t q = 0; q < 6; q++ )
28252 //{
28253 // zprint("PIXELARRAY script_drawing_commands[j][%d] is %d\n", q, script_drawing_commands[j][q]);
28254 //}
28255 int32_t arrayptr = script_drawing_commands[j][2]/10000;
28256 if ( !arrayptr ) //Don't crash because of vector size.
28257 {
28258 Z_scripterrlog("Invalid array pointer %d passed to Screen->DrawTiles(). Aborting.", arrayptr);
28259 break;
28260 }
28261 //zprint("Pixelarray array pointer is: %d\n", arrayptr);
28262 int32_t sz = ArrayH::getSize(arrayptr);
28263 //ArrayH::getSize(script_drawing_commands[j][2]/10000);
28264 //zprint("Pixelarray size is: %d\n", sz);
28265 v->resize(sz, 0);
28266 int32_t* pos = &v->at(0);
28267
28268 ArrayH::getValues(script_drawing_commands[j][2] / 10000, pos, sz);
28269 script_drawing_commands[j].SetVector(v);
28270 break;
28271 }
28272
28273 case LINESARRAY:
28274 {
28275 set_drawing_command_args(j, 2);
28276 std::vector<int32_t> *v = script_drawing_commands.GetVector();
28277 //for ( int32_t q = 0; q < 6; q++ )
28278 //{
28279 // zprint("PIXELARRAY script_drawing_commands[j][%d] is %d\n", q, script_drawing_commands[j][q]);
28280 //}
28281 int32_t arrayptr = script_drawing_commands[j][2]/10000;
28282 if ( !arrayptr ) //Don't crash because of vector size.
28283 {
28284 Z_scripterrlog("Invalid array pointer %d passed to Screen->Lines(). Aborting.", arrayptr);
28285 break;
28286 }
28287 //zprint("Pixelarray array pointer is: %d\n", arrayptr);
28288 int32_t sz = ArrayH::getSize(arrayptr);
28289 //ArrayH::getSize(script_drawing_commands[j][2]/10000);
28290 //zprint("Pixelarray size is: %d\n", sz);
28291 v->resize(sz, 0);
28292 int32_t* pos = &v->at(0);
28293
28294 ArrayH::getValues(script_drawing_commands[j][2] / 10000, pos, sz);
28295 script_drawing_commands[j].SetVector(v);
28296 break;
28297 }
28298
28299 /*
28300 historical-old-master
28301 set_drawing_command_args(j, 6);
28302 int32_t count = script_drawing_commands[j][2] / 10000; //todo: errcheck
28303
28304 int32_t* ptr = (int32_t*)script_drawing_commands.AllocateDrawBuffer(3 * count * sizeof(int32_t));
28305 int32_t* p = ptr;
28306
28307 ArrayH::getValues(script_drawing_commands[j][3] / 10000, p, count); p += count;
28308 ArrayH::getValues(script_drawing_commands[j][4] / 10000, p, count); p += count;
28309 ArrayH::getValues(script_drawing_commands[j][5] / 10000, p, count);
28310
28311 script_drawing_commands[j].SetPtr(ptr);
28312 */
28313 // Unused
28314 //const int32_t index = script_drawing_commands[j][19] = j;
28315
28316 //std::array *aptr = script_drawing_commands.GetString();
28317 //ArrayH::getString(script_drawing_commands[j][2] / 10000, *aptr);
28318 //script_drawing_commands[j].SetArray(aptr);
28319 //set_drawing_command_args(j, 2);
28320 //break;
28321
28322 case COMBOARRAYR:
28323 {
28324 set_drawing_command_args(j, 2);
28325 std::vector<int32_t> *v = script_drawing_commands.GetVector();
28326 //for ( int32_t q = 0; q < 6; q++ )
28327 //{
28328 // zprint("PIXELARRAY script_drawing_commands[j][%d] is %d\n", q, script_drawing_commands[j][q]);
28329 //}
28330 int32_t arrayptr = script_drawing_commands[j][2]/10000;
28331 if ( !arrayptr ) //Don't crash because of vector size.
28332 {
28333 Z_scripterrlog("Invalid array pointer %d passed to Screen->DrawCombos(). Aborting.", arrayptr);
28334 break;
28335 }
28336 //zprint("Pixelarray array pointer is: %d\n", arrayptr);
28337 int32_t sz = ArrayH::getSize(arrayptr);
28338 //ArrayH::getSize(script_drawing_commands[j][2]/10000);
28339 //zprint("Pixelarray size is: %d\n", sz);
28340 v->resize(sz, 0);
28341 int32_t* pos = &v->at(0);
28342
28343 ArrayH::getValues(script_drawing_commands[j][2] / 10000, pos, sz);
28344 script_drawing_commands[j].SetVector(v);
28345 break;
28346 }
28347 case POLYGONR:
28348 {
28349 set_drawing_command_args(j, 5);
28350
28351 int32_t arrayptr = script_drawing_commands[j][3]/10000;
28352 if ( !arrayptr ) //Don't crash because of vector size.
28353 {
28354 Z_scripterrlog("Invalid array pointer %d passed to Screen->Polygon(). Aborting.", arrayptr);
28355 break;
28356 }
28357 int32_t sz = ArrayH::getSize(arrayptr);
28358
28359 std::vector<int32_t> *v = script_drawing_commands.GetVector();
28360 v->resize(sz, 0);
28361
28362 int32_t* pos = &v->at(0);
28363
28364
28365 ArrayH::getValues(script_drawing_commands[j][3] / 10000, pos, sz);
28366 script_drawing_commands[j].SetVector(v);
28367 }
28368 break;
28369
28370 case DRAWTILER:
28371 825002 set_drawing_command_args(j, 15);
28372 825002 break;
28373
28374 case DRAWTILECLOAKEDR:
28375 set_drawing_command_args(j, 7);
28376 break;
28377
28378 case DRAWCOMBOR:
28379 1716768 set_drawing_command_args(j, 16);
28380 1716768 break;
28381
28382 case DRAWCOMBOCLOAKEDR:
28383 set_drawing_command_args(j, 7);
28384 break;
28385
28386 case FASTTILER:
28387 4737314 set_drawing_command_args(j, 6);
28388 4737314 break;
28389
28390 case FASTCOMBOR:
28391 17997642 set_drawing_command_args(j, 6);
28392 17997642 break;
28393
28394 case DRAWCHARR:
28395 936091 set_drawing_command_args(j, 10);
28396 936091 break;
28397
28398 case DRAWINTR:
28399 94003 set_drawing_command_args(j, 11);
28400 94003 break;
28401
28402 case SPLINER:
28403 set_drawing_command_args(j, 11);
28404 break;
28405
28406 case QUADR:
28407 9270 set_drawing_command_args(j, 15);
28408 9270 break;
28409
28410 case TRIANGLER:
28411 set_drawing_command_args(j, 13);
28412 break;
28413
28414 case BITMAPR:
28415 802244 set_drawing_command_args(j, 12);
28416 802244 break;
28417
28418 case BITMAPEXR:
28419 set_drawing_command_args(j, 16);
28420 break;
28421
28422 case DRAWLAYERR:
28423 4128276 set_drawing_command_args(j, 8);
28424 4128276 break;
28425
28426 case DRAWSCREENR:
28427 49303 set_drawing_command_args(j, 6);
28428 49303 break;
28429
28430 case QUAD3DR:
28431 {
28432 set_drawing_command_args(j, 8);
28433 int32_t arrayptr = script_drawing_commands[j][2]/10000;
28434 int32_t sz = ArrayH::getSize(arrayptr);
28435 arrayptr = script_drawing_commands[j][3]/10000;
28436 sz += ArrayH::getSize(arrayptr);
28437 arrayptr = script_drawing_commands[j][4]/10000;
28438 sz += ArrayH::getSize(arrayptr);
28439 arrayptr = script_drawing_commands[j][5]/10000;
28440 sz += ArrayH::getSize(arrayptr);
28441 std::vector<int32_t> *v = script_drawing_commands.GetVector();
28442 v->resize(sz, 0);
28443
28444 int32_t* pos = &v->at(0);
28445 int32_t* uv = &v->at(12);
28446 int32_t* col = &v->at(20);
28447 int32_t* size = &v->at(24);
28448
28449 ArrayH::getValues((script_drawing_commands[j][2] / 10000), pos, 12);
28450 ArrayH::getValues((script_drawing_commands[j][3] / 10000), uv, 8);
28451 ArrayH::getValues((script_drawing_commands[j][4] / 10000), col, 4);
28452 //FFCore.getValues2(script_drawing_commands[j][5] / 10000, size, 2);
28453 ArrayH::getValues((script_drawing_commands[j][5] / 10000), size, 2);
28454
28455 script_drawing_commands[j].SetVector(v);
28456 }
28457 break;
28458
28459 case TRIANGLE3DR:
28460 {
28461 set_drawing_command_args(j, 8);
28462
28463 int32_t arrayptr = script_drawing_commands[j][2]/10000;
28464 int32_t sz = ArrayH::getSize(arrayptr);
28465 arrayptr = script_drawing_commands[j][3]/10000;
28466 sz += ArrayH::getSize(arrayptr);
28467 arrayptr = script_drawing_commands[j][4]/10000;
28468 sz += ArrayH::getSize(arrayptr);
28469 arrayptr = script_drawing_commands[j][5]/10000;
28470 sz += ArrayH::getSize(arrayptr);
28471
28472 std::vector<int32_t> *v = script_drawing_commands.GetVector();
28473 v->resize(sz, 0);
28474
28475 int32_t* pos = &v->at(0);
28476 int32_t* uv = &v->at(9);
28477 int32_t* col = &v->at(15);
28478 int32_t* size = &v->at(18);
28479
28480 ArrayH::getValues(script_drawing_commands[j][2] / 10000, pos, 8);
28481 ArrayH::getValues(script_drawing_commands[j][3] / 10000, uv, 6);
28482 ArrayH::getValues(script_drawing_commands[j][4] / 10000, col, 3);
28483 ArrayH::getValues(script_drawing_commands[j][5] / 10000, size, 2);
28484
28485 script_drawing_commands[j].SetVector(v);
28486 }
28487 break;
28488
28489 case DRAWSTRINGR:
28490 {
28491 1240874 set_drawing_command_args(j, 9);
28492 // Unused
28493 //const int32_t index = script_drawing_commands[j][19] = j;
28494
28495 1240874 string *str = script_drawing_commands.GetString();
28496 1240874 ArrayH::getString(script_drawing_commands[j][8] / 10000, *str, 256);
28497 1240874 script_drawing_commands[j].SetString(str);
28498 }
28499 1240874 break;
28500
28501 case DRAWSTRINGR2:
28502 {
28503 144648 set_drawing_command_args(j, 11);
28504 // Unused
28505 //const int32_t index = script_drawing_commands[j][19] = j;
28506
28507 144648 string *str = script_drawing_commands.GetString();
28508 144648 ArrayH::getString(script_drawing_commands[j][8] / 10000, *str, 256);
28509 144648 script_drawing_commands[j].SetString(str);
28510 }
28511 144648 break;
28512
28513 case BMPRECTR:
28514 7806 set_user_bitmap_command_args(j, 12); script_drawing_commands[j][17] = SH::read_stack(ri->sp+12);
28515 //Pop the args off the stack first. Then pop the pointer and push it to sdci[17].
28516 //The pointer for the bitmap variable (its literal value) is always ri->sp+numargs, so, with 12 args, it is sp+12.
28517 7806 break;
28518
28519 case BMPFRAMER:
28520 set_user_bitmap_command_args(j, 9);
28521 script_drawing_commands[j][17] = SH::read_stack(ri->sp+9);
28522 break;
28523
28524 case CLEARBITMAP:
28525 {
28526 18927 set_user_bitmap_command_args(j, 1);
28527 18927 script_drawing_commands[j][17] = SH::read_stack(ri->sp+1);
28528 18927 break;
28529 }
28530 case BITMAPCLEARTOCOLOR:
28531 {
28532 2600 set_user_bitmap_command_args(j, 2);
28533 2600 script_drawing_commands[j][17] = SH::read_stack(ri->sp+2);
28534 2600 break;
28535 }
28536 case REGENERATEBITMAP:
28537 {
28538 26528 set_user_bitmap_command_args(j, 3);
28539 26528 script_drawing_commands[j][17] = SH::read_stack(ri->sp+3);
28540 26528 break;
28541 }
28542 case BMPPOLYGONR:
28543 {
28544 set_user_bitmap_command_args(j, 5);
28545 script_drawing_commands[j][17] = SH::read_stack(ri->sp+5);
28546 int32_t arrayptr = script_drawing_commands[j][3]/10000;
28547 if ( !arrayptr ) //Don't crash because of vector size.
28548 {
28549 Z_scripterrlog("Invalid array pointer %d passed to Screen->Polygon(). Aborting.", arrayptr);
28550 break;
28551 }
28552 int32_t sz = ArrayH::getSize(arrayptr);
28553
28554 std::vector<int32_t> *v = script_drawing_commands.GetVector();
28555 v->resize(sz, 0);
28556
28557 int32_t* pos = &v->at(0);
28558
28559
28560 ArrayH::getValues(script_drawing_commands[j][3] / 10000, pos, sz);
28561 script_drawing_commands[j].SetVector(v);
28562 }
28563 break;
28564 case READBITMAP:
28565 {
28566 //zprint("Calling %s\n","READBITMAP");
28567 set_user_bitmap_command_args(j, 2);
28568 script_drawing_commands[j][17] = SH::read_stack(ri->sp+2);
28569 string *str = script_drawing_commands.GetString();
28570 ArrayH::getString(script_drawing_commands[j][2] / 10000, *str, 256);
28571
28572 //char cptr = new char[str->size()+1]; // +1 to account for \0 byte
28573 //strncpy(cptr, str->c_str(), str->size());
28574
28575 if(get_qr(qr_BITMAP_AND_FILESYSTEM_PATHS_ALWAYS_RELATIVE))
28576 {
28577 char buf[2048+1] = {0};
28578 if(FFCore.get_scriptfile_path(buf, str->c_str()))
28579 (*str) = buf;
28580 }
28581 regulate_path(*str);
28582
28583 //zprint("READBITMAP string is %s\n", cptr);
28584
28585 script_drawing_commands[j].SetString(str);
28586 break;
28587 }
28588 case WRITEBITMAP:
28589 {
28590 //zprint("Calling %s\n","WRITEBITMAP");
28591 set_user_bitmap_command_args(j, 3);
28592 script_drawing_commands[j][17] = SH::read_stack(ri->sp+3);
28593 std::string *str = script_drawing_commands.GetString();
28594 ArrayH::getString(script_drawing_commands[j][2] / 10000, *str, 256);
28595
28596
28597 //char *cptr = new char[str->size()+1]; // +1 to account for \0 byte
28598 //strncpy(cptr, str->c_str(), str->size());
28599
28600 if(get_qr(qr_BITMAP_AND_FILESYSTEM_PATHS_ALWAYS_RELATIVE))
28601 {
28602 char buf[2048+1] = {0};
28603 if(FFCore.get_scriptfile_path(buf, str->c_str()))
28604 (*str) = buf;
28605 }
28606 regulate_path(*str);
28607
28608 //zprint("WRITEBITMAP string is %s\n", cptr);
28609 script_drawing_commands[j].SetString(str);
28610 break;
28611 }
28612
28613 1480 case BMPCIRCLER: set_user_bitmap_command_args(j, 11); script_drawing_commands[j][17] = SH::read_stack(ri->sp+11); break;
28614 case BMPARCR: set_user_bitmap_command_args(j, 14); script_drawing_commands[j][17] = SH::read_stack(ri->sp+14); break;
28615 502 case BMPELLIPSER: set_user_bitmap_command_args(j, 12); script_drawing_commands[j][17] = SH::read_stack(ri->sp+12); break;
28616 144 case BMPLINER: set_user_bitmap_command_args(j, 11); script_drawing_commands[j][17] = SH::read_stack(ri->sp+11); break;
28617 case BMPSPLINER: set_user_bitmap_command_args(j, 11); script_drawing_commands[j][17] = SH::read_stack(ri->sp+11); break;
28618 80910 case BMPPUTPIXELR: set_user_bitmap_command_args(j, 8); script_drawing_commands[j][17] = SH::read_stack(ri->sp+8); break;
28619 59173 case BMPDRAWTILER: set_user_bitmap_command_args(j, 15); script_drawing_commands[j][17] = SH::read_stack(ri->sp+15); break;
28620 case BMPDRAWTILECLOAKEDR: set_user_bitmap_command_args(j, 7); script_drawing_commands[j][17] = SH::read_stack(ri->sp+7); break;
28621 821 case BMPDRAWCOMBOR: set_user_bitmap_command_args(j, 16); script_drawing_commands[j][17] = SH::read_stack(ri->sp+16); break;
28622 case BMPDRAWCOMBOCLOAKEDR: set_user_bitmap_command_args(j, 7); script_drawing_commands[j][17] = SH::read_stack(ri->sp+7); break;
28623 162686 case BMPFASTTILER: set_user_bitmap_command_args(j, 6); script_drawing_commands[j][17] = SH::read_stack(ri->sp+6); break;
28624 784 case BMPFASTCOMBOR: set_user_bitmap_command_args(j, 6); script_drawing_commands[j][17] = SH::read_stack(ri->sp+6); break;
28625 case BMPDRAWCHARR: set_user_bitmap_command_args(j, 10); script_drawing_commands[j][17] = SH::read_stack(ri->sp+10); break;
28626 case BMPDRAWINTR: set_user_bitmap_command_args(j, 11); script_drawing_commands[j][17] = SH::read_stack(ri->sp+11); break;
28627 case BMPDRAWSTRINGR:
28628 {
28629 set_user_bitmap_command_args(j, 9);
28630 script_drawing_commands[j][17] = SH::read_stack(ri->sp+9);
28631 // Unused
28632 //const int32_t index = script_drawing_commands[j][19] = j;
28633
28634 string *str = script_drawing_commands.GetString();
28635 ArrayH::getString(script_drawing_commands[j][8] / 10000, *str, 256);
28636 script_drawing_commands[j].SetString(str);
28637
28638 }
28639 break;
28640 case BMPDRAWSTRINGR2:
28641 {
28642 45504 set_user_bitmap_command_args(j, 11);
28643 45504 script_drawing_commands[j][17] = SH::read_stack(ri->sp+11);
28644 // Unused
28645 //const int32_t index = script_drawing_commands[j][19] = j;
28646
28647 45504 string *str = script_drawing_commands.GetString();
28648 45504 ArrayH::getString(script_drawing_commands[j][8] / 10000, *str, 256);
28649 45504 script_drawing_commands[j].SetString(str);
28650
28651 }
28652 45504 break;
28653 case BMPQUADR: set_user_bitmap_command_args(j, 16); script_drawing_commands[j][17] = SH::read_stack(ri->sp+16); break;
28654 case BMPQUAD3DR:
28655 {
28656 set_drawing_command_args(j, 9);
28657 std::vector<int32_t> *v = script_drawing_commands.GetVector();
28658 v->resize(26, 0);
28659
28660 int32_t* pos = &v->at(0);
28661 int32_t* uv = &v->at(12);
28662 int32_t* col = &v->at(20);
28663 int32_t* size = &v->at(24);
28664
28665
28666 ArrayH::getValues(script_drawing_commands[j][2] / 10000, pos, 12);
28667 ArrayH::getValues(script_drawing_commands[j][3] / 10000, uv, 8);
28668 ArrayH::getValues(script_drawing_commands[j][4] / 10000, col, 4);
28669 ArrayH::getValues(script_drawing_commands[j][5] / 10000, size, 2);
28670
28671 script_drawing_commands[j].SetVector(v);
28672 script_drawing_commands[j][17] = SH::read_stack(ri->sp+9);
28673
28674 }
28675 break;
28676 case BMPTRIANGLER: set_user_bitmap_command_args(j, 14); script_drawing_commands[j][17] = SH::read_stack(ri->sp+14); break;
28677 case BMPTRIANGLE3DR:
28678 {
28679 set_drawing_command_args(j, 9);
28680
28681 std::vector<int32_t> *v = script_drawing_commands.GetVector();
28682 v->resize(20, 0);
28683
28684 int32_t* pos = &v->at(0);
28685 int32_t* uv = &v->at(9);
28686 int32_t* col = &v->at(15);
28687 int32_t* size = &v->at(18);
28688
28689
28690 ArrayH::getValues(script_drawing_commands[j][2] / 10000, pos, 8);
28691 ArrayH::getValues(script_drawing_commands[j][3] / 10000, uv, 6);
28692 ArrayH::getValues(script_drawing_commands[j][4] / 10000, col, 3);
28693 ArrayH::getValues(script_drawing_commands[j][5] / 10000, size, 2);
28694
28695 script_drawing_commands[j].SetVector(v);
28696 script_drawing_commands[j][17] = SH::read_stack(ri->sp+9);
28697 break;
28698 }
28699
28700 case BMPDRAWLAYERR:
28701 1152 set_user_bitmap_command_args(j, 8);
28702 1152 script_drawing_commands[j][17] = SH::read_stack(ri->sp+8);
28703 1152 break;
28704 case BMPDRAWLAYERSOLIDR:
28705 case BMPDRAWLAYERCFLAGR:
28706 case BMPDRAWLAYERCTYPER:
28707 case BMPDRAWLAYERCIFLAGR:
28708 case BMPDRAWLAYERSOLIDITYR: set_user_bitmap_command_args(j, 9); script_drawing_commands[j][17] = SH::read_stack(ri->sp+9); break;
28709 case BMPDRAWSCREENR:
28710 case BMPDRAWSCREENSOLIDR:
28711 case BMPDRAWSCREENSOLID2R:
28712 case BMPDRAWSCREENCOMBOFR:
28713 case BMPDRAWSCREENCOMBOIR:
28714 case BMPDRAWSCREENCOMBOTR:
28715 2048 set_user_bitmap_command_args(j, 6); script_drawing_commands[j][17] = SH::read_stack(ri->sp+6); break;
28716 case BITMAPGETPIXEL:
28717 {
28718 //UNUSED
28719 // for(int32_t q = 0; q < 20; q++)
28720 // {
28721 // Z_scripterrlog("getpixel SH::read_stack(ri->sp+%d) is: %d\n", q, SH::read_stack(ri->sp+q));
28722 // }
28723 set_user_bitmap_command_args(j, 3); script_drawing_commands[j][17] = SH::read_stack(ri->sp+3);
28724 break;
28725 }
28726 case BMPBLIT:
28727 {
28728 229546 set_user_bitmap_command_args(j, 16);
28729 //for(int32_t q = 0; q < 8; ++q )
28730 //Z_scripterrlog("FFscript blit() ri->d[%d] is: %d\n", q, ri->d[q]);
28731 229546 script_drawing_commands[j][17] = SH::read_stack(ri->sp+16);
28732 229546 break;
28733 }
28734 case BMPBLITTO:
28735 {
28736 906 set_user_bitmap_command_args(j, 16);
28737 //for(int32_t q = 0; q < 8; ++q )
28738 //Z_scripterrlog("FFscript blit() ri->d[%d] is: %d\n", q, ri->d[q]);
28739 906 script_drawing_commands[j][17] = SH::read_stack(ri->sp+16);
28740 906 break;
28741 }
28742 case BMPMODE7:
28743 {
28744 set_user_bitmap_command_args(j, 13);
28745 //for(int32_t q = 0; q < 8; ++q )
28746 //Z_scripterrlog("FFscript blit() ri->d[%d] is: %d\n", q, ri->d[q]);
28747 script_drawing_commands[j][17] = SH::read_stack(ri->sp+13);
28748 break;
28749 }
28750
28751 case BMPWRITETILE:
28752 {
28753 set_user_bitmap_command_args(j, 6);
28754 script_drawing_commands[j][17] = SH::read_stack(ri->sp+6);
28755 break;
28756 }
28757 case BMPDITHER:
28758 {
28759 set_user_bitmap_command_args(j, 5);
28760 script_drawing_commands[j][17] = SH::read_stack(ri->sp+5);
28761 break;
28762 }
28763 case BMPMASKDRAW:
28764 {
28765 906 set_user_bitmap_command_args(j, 3);
28766 906 script_drawing_commands[j][4] = 0x01 * 10000L;
28767 906 script_drawing_commands[j][5] = 0xFF * 10000L;
28768 906 script_drawing_commands[j][17] = SH::read_stack(ri->sp+3);
28769 906 break;
28770 }
28771 case BMPMASKDRAW2:
28772 {
28773 set_user_bitmap_command_args(j, 4);
28774 script_drawing_commands[j][5] = script_drawing_commands[j][4];
28775 script_drawing_commands[j][0] = BMPMASKDRAW;
28776 script_drawing_commands[j][17] = SH::read_stack(ri->sp+4);
28777 break;
28778 }
28779 case BMPMASKDRAW3:
28780 {
28781 set_user_bitmap_command_args(j, 5);
28782 script_drawing_commands[j][0] = BMPMASKDRAW;
28783 script_drawing_commands[j][17] = SH::read_stack(ri->sp+5);
28784 break;
28785 }
28786 case BMPMASKBLIT:
28787 {
28788 set_user_bitmap_command_args(j, 4);
28789 script_drawing_commands[j][5] = 0x01 * 10000L;
28790 script_drawing_commands[j][6] = 0xFF * 10000L;
28791 script_drawing_commands[j][17] = SH::read_stack(ri->sp+4);
28792 break;
28793 }
28794 case BMPMASKBLIT2:
28795 {
28796 set_user_bitmap_command_args(j, 5);
28797 script_drawing_commands[j][6] = script_drawing_commands[j][5];
28798 script_drawing_commands[j][0] = BMPMASKBLIT;
28799 script_drawing_commands[j][17] = SH::read_stack(ri->sp+5);
28800 break;
28801 }
28802 case BMPMASKBLIT3:
28803 {
28804 set_user_bitmap_command_args(j, 6);
28805 script_drawing_commands[j][0] = BMPMASKBLIT;
28806 script_drawing_commands[j][17] = SH::read_stack(ri->sp+6);
28807 break;
28808 }
28809 case BMPREPLCOLOR:
28810 case BMPSHIFTCOLOR:
28811 {
28812 6363 set_user_bitmap_command_args(j, 4);
28813 6363 script_drawing_commands[j][17] = SH::read_stack(ri->sp+4);
28814 6363 break;
28815 }
28816 }
28817 37907639 script_drawing_commands.mark_dirty(script_drawing_commands[j][1]/10000);
28818 37907639 }
28819
28820 3535588 void do_set_rendertarget(bool)
28821 {
28822 3535588 int32_t target = int32_t(SH::read_stack(ri->sp) / 10000);
28823 3535588 zscriptDrawingRenderTarget->SetCurrentRenderTarget(target);
28824 3535588 }
28825
28826 170812 void do_sfx(const bool v)
28827 {
28828 170812 int32_t ID = SH::get_arg(sarg1, v) / 10000;
28829
28830
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 170808 times.
170812 if(BC::checkSFXID(ID, "Game->PlaySound") != SH::_NoError)
28831 4 return;
28832
28833 170808 sfx(ID);
28834 170812 }
28835
28836 void do_sfx_ex(const bool restart)
28837 {
28838 int32_t ID = SH::read_stack(ri->sp + 4) / 10000;
28839 int32_t vol = vbound(SH::read_stack(ri->sp + 3), 0, 10000 * 100);
28840 int32_t pan = vbound(SH::read_stack(ri->sp + 2)/10000 + 128, 0, 255);
28841 int32_t freq = SH::read_stack(ri->sp + 1);
28842 bool loop = SH::read_stack(ri->sp) / 10000;
28843
28844 if (BC::checkSFXID(ID, restart?"Audio->PlaySound":"Audio->AdjustSound") != SH::_NoError)
28845 return;
28846
28847 if (!restart && !sfx_allocated(ID))
28848 return;
28849
28850 sfx(ID, pan, loop, restart, vol, freq);
28851 }
28852
28853 static int get_sfx_completion()
28854 {
28855 int32_t ID = get_register(sarg1) / 10000;
28856
28857 if (!sfx_allocated(ID))
28858 {
28859 return -10000;
28860 }
28861
28862 uint64_t sample_pos = voice_get_position(sfx_voice[ID]);
28863
28864 if (sample_pos < 0)
28865 {
28866 return -10000;
28867 }
28868
28869 uint32_t sample_length = sfx_get_length(ID);
28870 uint64_t res = (sample_pos * 10000 * 100) / sample_length;
28871 return int32_t(res);
28872 }
28873
28874 void do_get_sfx_completion()
28875 {
28876 int32_t ID = get_register(sarg1) / 10000;
28877 if (replay_is_active())
28878 replay_step_comment(fmt::format("ID {}", ID));
28879 int32_t value = replay_get_state(ReplayStateType::SfxPosition, get_sfx_completion);
28880 set_register(sarg1, value);
28881 }
28882
28883 int32_t FFScript::do_get_internal_uid_npc(int32_t index)
28884 {
28885 return ((int32_t)guys.spr(index)->getUID());
28886 }
28887 int32_t FFScript::do_get_internal_uid_item(int32_t index)
28888 {
28889 return ((int32_t)items.spr(index)->getUID());
28890 }
28891 int32_t FFScript::do_get_internal_uid_lweapon(int32_t index)
28892 {
28893 return ((int32_t)Lwpns.spr(index)->getUID());
28894 }
28895 int32_t FFScript::do_get_internal_uid_eweapon(int32_t index)
28896 {
28897 return ((int32_t)Ewpns.spr(index)->getUID());
28898 }
28899
28900 void FFScript::AlloffLimited(int32_t flagset)
28901 {
28902 clear_bitmap(msg_txt_display_buf);
28903 clear_bitmap(msg_bg_display_buf);
28904 clear_bitmap(msg_portrait_display_buf);
28905 set_clip_state(msg_txt_display_buf, 1);
28906 set_clip_state(msg_bg_display_buf, 1);
28907 set_clip_state(msg_portrait_display_buf, 1);
28908
28909
28910 clear_bitmap(pricesdisplaybuf);
28911 set_clip_state(pricesdisplaybuf, 1);
28912
28913 if(items.idCount(iPile))
28914 {
28915 loadlvlpal(DMaps[currdmap].color);
28916 }
28917
28918 /*
28919
28920 #define warpFlagCLEARITEMS 0x200
28921 #define warpFlagCLEARGUYS 0x400
28922 #define warpFlagCLEARLWEAPONS 0x800
28923 #define warpFlagCLEAREWEAPONS 0x1000
28924 #define warpFlagCLEARHOOKSHOT 0x2000
28925 #define warpFlagCLEARDECORATIONS 0x4000
28926 #define warpFlagCLEARPARTICLES 0x8000
28927 */
28928
28929 if ( (flagset&warpFlagCLEARITEMS) ) items.clear();
28930 if ( (flagset&warpFlagCLEARGUYS) ) guys.clear();
28931 if ( (flagset&warpFlagCLEARLWEAPONS) ) Lwpns.clear();
28932 if ( (flagset&warpFlagCLEAREWEAPONS) ) Ewpns.clear();
28933 if ( (flagset&warpFlagCLEARHOOKSHOT) )
28934 {
28935 chainlinks.clear();
28936 Hero.reset_hookshot();
28937 }
28938 if ( (flagset&warpFlagCLEARDECORATIONS) ) decorations.clear();
28939 if ( (flagset&warpFlagCLEARPARTICLES) ) particles.clear();
28940 clearScriptHelperData();
28941
28942
28943
28944 clearScriptHelperData();
28945
28946 lensclk = 0;
28947 lensid=-1;
28948 drawguys=true;
28949 down_control_states[btnUp] =
28950 down_control_states[btnDown] =
28951 down_control_states[btnLeft] =
28952 down_control_states[btnRight] =
28953 down_control_states[btnA] =
28954 down_control_states[btnB] =
28955 down_control_states[btnS] = true;
28956
28957 if(watch && !cheat_superman)
28958 {
28959 Hero.setClock(false);
28960 }
28961
28962 // if(watch)
28963 // Hero.setClock(false);
28964 watch=freeze_guys=loaded_guys=loaded_enemies=blockpath=false;
28965
28966 for(int32_t i=0; i<176; i++)
28967 guygrid[i]=0;
28968
28969 for(int32_t i=0; i<MAXFFCS; i++)
28970 guygridffc[i]=0;
28971
28972
28973 sle_clk=0;
28974
28975 if(usebombpal)
28976 {
28977 memcpy(RAMpal, tempbombpal, PAL_SIZE*sizeof(RGB));
28978 refreshpal=true;
28979 usebombpal=false;
28980 }
28981
28982
28983 }
28984
28985 32 void doWarpEffect(int32_t warpEffect, bool out)
28986 {
28987
1/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
32 switch(warpEffect)
28988 {
28989 case warpEffectZap:
28990 if(out) zapout();
28991 else zapin();
28992 break;
28993 case warpEffectWave:
28994 if(out) wavyout(false);
28995 else wavyin();
28996 break;
28997 case warpEffectInstant:
28998 if(out) blackscr(30,true);
28999 break;
29000 case warpEffectMozaic:
29001 //!TODO Unimplemented
29002 break;
29003 case warpEffectOpen:
29004 if(out) closescreen();
29005 else openscreen();
29006 break;
29007 }
29008 32 }
29009
29010 void FFScript::queueWarp(int32_t wtype, int32_t tdm, int32_t tscr, int32_t wx, int32_t wy,
29011 int32_t weff, int32_t wsfx, int32_t wflag, int32_t wdir)
29012 {
29013 warpex[wexActive] = 1;
29014 warpex[wexType] = wtype;
29015 warpex[wexDMap] = tdm;
29016 warpex[wexScreen] = tscr;
29017 warpex[wexX] = wx;
29018 warpex[wexY] = wy;
29019 warpex[wexEffect] = weff;
29020 warpex[wexSound] = wsfx;
29021 warpex[wexFlags] = wflag;
29022 warpex[wexDir] = wdir;
29023 }
29024
29025 16 bool FFScript::warp_player(int32_t warpType, int32_t dmapID, int32_t scrID, int32_t warpDestX, int32_t warpDestY, int32_t warpEffect, int32_t warpSound, int32_t warpFlags, int32_t heroFacesDir)
29026 {
29027 if(DEVLOGGING)
29028 {
29029 zprint("FFScript::warp_player() arg %s is: %d \n", "warpType", warpType);
29030 zprint("FFScript::warp_player() arg %s is: %d \n", "dmapID", dmapID);
29031 zprint("FFScript::warp_player() arg %s is: %d \n", "scrID", scrID);
29032 zprint("FFScript::warp_player() arg %s is: %d \n", "warpDestX", warpDestX);
29033 zprint("FFScript::warp_player() arg %s is: %d \n", "warpDestY", warpDestY);
29034 zprint("FFScript::warp_player() arg %s is: %d \n", "warpEffect", warpEffect);
29035 zprint("FFScript::warp_player() arg %s is: %d \n", "warpSound", warpSound);
29036 zprint("FFScript::warp_player() arg %s is: %d \n", "warpFlags", warpFlags);
29037 zprint("FFScript::warp_player() arg %s is: %d \n", "heroFacesDir", heroFacesDir);
29038 }
29039
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( ((unsigned)dmapID) >= MAXDMAPS )
29040 {
29041 Z_scripterrlog("Invalid DMap ID (%d) passed to WarpEx(). Aborting.\n", dmapID);
29042 return false;
29043 }
29044
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( ((unsigned)scrID) >= MAPSCRS )
29045 {
29046 Z_scripterrlog("Invalid Screen ID (%d) passed to WarpEx(). Aborting.\n", scrID);
29047 return false;
29048 }
29049 //Extra sanity guard.
29050
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( DMaps[dmapID].map*MAPSCRS+DMaps[dmapID].xoff+scrID >= (int32_t)TheMaps.size() )
29051 {
29052 Z_scripterrlog("Invalid destination passed to WarpEx(). Aborting.\n");
29053 return false;
29054 }
29055 16 byte t = 0;
29056 16 t=(currscr<128)?0:1;
29057 16 bool overlay=false;
29058 16 bool intradmap = (dmapID == currdmap);
29059 16 int32_t olddmap = currdmap;
29060 //if ( intradmap )
29061 //{
29062 // initZScriptDMapScripts(); //Not needed.
29063 //}
29064
29065
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( warpType == wtNOWARP ) { Z_eventlog("Used a Cancel Warped to DMap %d: %s, screen %d", currdmap, DMaps[currdmap].name,currscr); return false; }
29066 16 int32_t mapID = (DMaps[dmapID].map+1);
29067 16 int32_t dest_dmap_xoff = DMaps[dmapID].xoff;
29068 //mapscr *m = &TheMaps[mapID * MAPSCRS + scrID];
29069
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 mapscr *m = &TheMaps[(zc_max((mapID)-1,0) * MAPSCRS + dest_dmap_xoff + scrID)];
29070
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if ( warpFlags&warpFlagNOSTEPFORWARD ) FFCore.temp_no_stepforward = 1;
29071 16 int32_t wx = 0, wy = 0;
29072
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( warpDestX < 0 )
29073 {
29074 if(DEVLOGGING) zprint("WarpEx() was set to warp return point:%d\n", warpDestY);
29075
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if ( (unsigned)warpDestY < 4 )
29076 {
29077 16 wx = m->warpreturnx[warpDestY];
29078 16 wy = m->warpreturny[warpDestY];
29079 if(DEVLOGGING)
29080 {
29081 zprint("WarpEx Return Point X is: %d\n",wx);
29082 zprint("WarpEx Return Point Y is: %d\n",wy);
29083 }
29084 16 }
29085 else
29086 {
29087 if ( warpDestY == 5 || warpDestY < 0)
29088 {
29089 //Pit warp
29090 wx = Hero.getX();
29091 wy = Hero.getY();
29092 }
29093 else
29094 {
29095 Z_scripterrlog("Invalid Warp Return Square Type (%d) provided as an arg to Player->WarpEx().\n",warpDestY);
29096 return false;
29097 }
29098 }
29099 16 }
29100 else
29101 {
29102 if ( (unsigned)warpDestX < 256 && (unsigned)warpDestY < 176 )
29103 {
29104 wx = warpDestX;
29105 wy = warpDestY;
29106 }
29107 else
29108 {
29109 Z_scripterrlog("Invalid pixel coordinates of x = %d, y = %d, supplied to Player->WarpEx()\n",warpDestX,warpDestY);
29110 return false;
29111 }
29112
29113 }
29114 //zprint("FFCore.warp_player reached line: %d \n", 15918);
29115 //warp coordinates are wx, wy, not x, y! -Z
29116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( !(warpFlags&warpFlagDONTKILLSCRIPTDRAWS) ) script_drawing_commands.Clear();
29117 //we also need to check if dmaps are sideview here! -Z
29118 //Likewise, we need to add that check to the normal Hero:;dowarp(0
29119 16 bool wasSideview = isSideViewGravity(t); //((tmpscr[t].flags7 & fSIDEVIEW)!=0 || DMaps[currdmap].sideview) && !ignoreSideview;
29120 //zprint("FFCore.warp_player reached line: %d \n", 15925);
29121 //zprint("FFCore.warp_player war type is: %d \n", warpType);
29122
29123 //int32_t last_entr_scr = -1;
29124 //int32_t last_entr_dmap = -1;
29125
29126
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if ( warpType < wtEXIT ) warpType = wtIWARP; //Sanity check. We can't use wtCave, or wtPassage, with scritped warps at present.
29127 16 Hero.is_warping = true;
29128
1/5
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
16 switch(warpType)
29129 {
29130
29131 //wtCAVE, wtPASS, wtEXIT, wtSCROLL, wtIWARP, wtIWARPBLK, wtIWARPOPEN,
29132 //wtIWARPZAP, wtIWARPWAVE, wtNOWARP, wtWHISTLE, wtMAX
29133
29134
29135 case wtIWARP:
29136 case wtIWARPBLK:
29137 case wtIWARPOPEN:
29138 case wtIWARPZAP:
29139 case wtIWARPWAVE:
29140 {
29141 //zprint("FFCore.warp_player reached line: %d \n", 15936);
29142 16 bool wasswimming = (Hero.getAction()==swimming);
29143 16 bool wassideswim = (Hero.getAction()==sideswimming);
29144 16 int32_t olddiveclk = Hero.diveclk;
29145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( !(warpFlags&warpFlagDONTCLEARSPRITES) )
29146 {
29147 16 ALLOFF();
29148 16 }
29149 else FFCore.AlloffLimited(warpFlags);
29150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( !(warpFlags&warpFlagDONTKILLMUSIC) ) music_stop();
29151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( !(warpFlags&warpFlagDONTKILLSOUNDS) ) kill_sfx();
29152 16 sfx(warpSound);
29153
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(wasswimming)
29154 {
29155 Hero.setAction(swimming); FFCore.setHeroAction(swimming);
29156 Hero.diveclk = olddiveclk;
29157 }
29158
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(wassideswim)
29159 {
29160 Hero.setAction(sideswimming); FFCore.setHeroAction(sideswimming);
29161 Hero.diveclk = 0;
29162 }
29163 //zprint("FFCore.warp_player reached line: %d \n", 15948);
29164 16 doWarpEffect(warpEffect, true);
29165 //zprint("FFCore.warp_player reached line: %d \n", 15973);
29166 16 int32_t c = DMaps[currdmap].color;
29167 16 bool changedlevel = false;
29168 16 bool changeddmap = false;
29169
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(currdmap != dmapID)
29170 {
29171 16 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
29172 16 changeddmap = true;
29173 16 }
29174
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(dlevel != DMaps[dmapID].level)
29175 {
29176 16 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
29177 16 changedlevel = true;
29178 16 }
29179 16 dlevel = DMaps[dmapID].level;
29180 16 currdmap = dmapID;
29181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(changeddmap)
29182 {
29183 16 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
29184 16 }
29185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(changedlevel)
29186 {
29187 16 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
29188 16 }
29189 16 currmap = DMaps[currdmap].map;
29190 16 init_dmap();
29191 16 update_subscreens(dmapID);
29192
29193 16 ringcolor(false);
29194
29195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(DMaps[currdmap].color != c)
29196 16 loadlvlpal(DMaps[currdmap].color);
29197
29198 16 homescr = currscr = scrID + DMaps[currdmap].xoff;
29199
29200 16 lightingInstant(); // Also sets naturaldark
29201
29202 16 loadscr(0,currdmap,currscr,-1,overlay);
29203
29204 16 Hero.x = (zfix)wx;
29205 16 Hero.y = (zfix)wy;
29206
29207
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 switch(heroFacesDir)
29208 {
29209 case up:
29210 case down:
29211 case left:
29212 case right:
29213 Hero.dir = heroFacesDir;
29214 break;
29215 default:
29216
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if((int32_t)Hero.x==(zfix)0)
29217 {
29218 Hero.dir=right;
29219 }
29220
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if((int32_t)Hero.x==(zfix)240)
29221 {
29222 Hero.dir=left;
29223 }
29224
29225
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if((int32_t)Hero.y==(zfix)0)
29226 {
29227 Hero.dir=down;
29228 }
29229
29230
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if((int32_t)Hero.y==(zfix)160)
29231 {
29232 Hero.dir=up;
29233 }
29234 16 }
29235
29236 16 markBmap(Hero.dir^1);
29237
29238
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 16 times.
16 if(iswaterex(MAPCOMBO((int32_t)Hero.x,(int32_t)Hero.y+8), currmap, currscr, -1, Hero.x, Hero.y+8, true) && _walkflag((int32_t)Hero.x,(int32_t)Hero.y+8,0) && current_item(itype_flippers))
29239 {
29240 Hero.hopclk=0xFF;
29241 Hero.attackclk = Hero.charging = Hero.spins = 0;
29242 if (isSideViewHero() && get_qr(qr_SIDESWIM)) {Hero.setAction(sideswimming); FFCore.setHeroAction(sideswimming);}
29243 else {Hero.setAction(swimming); FFCore.setHeroAction(swimming);}
29244 }
29245 else
29246 {
29247 16 Hero.setAction(none); FFCore.setHeroAction(none);
29248 }
29249
29250 //preloaded freeform combos
29251 16 ffscript_engine(true);
29252
29253 16 putscr(scrollbuf,0,0,tmpscr);
29254 16 putscrdoors(scrollbuf,0,0,tmpscr);
29255
29256 16 doWarpEffect(warpEffect, false);
29257 16 show_subscreen_life=true;
29258 16 show_subscreen_numbers=true;
29259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( !(warpFlags&warpFlagDONTKILLMUSIC) ) Play_Level_Music();
29260 16 currcset=DMaps[currdmap].color;
29261 16 dointro();
29262 16 Hero.set_respawn_point();
29263 16 Hero.trySideviewLadder();
29264
29265 16 break;
29266 }
29267
29268
29269 case wtEXIT:
29270 {
29271 //zprint("%s was called with a warp type of Entrance/Exit\n", "Player->WarpEx()");
29272 lighting(false,false,pal_litRESETONLY);//Reset permLit, and do nothing else; lighting was not otherwise called on a wtEXIT warp.
29273 ALLOFF();
29274 if ( !(warpFlags&warpFlagDONTKILLMUSIC) ) music_stop();
29275 if ( !(warpFlags&warpFlagDONTKILLSOUNDS) ) kill_sfx();
29276 sfx(warpSound);
29277 blackscr(30,false);
29278 bool changedlevel = false;
29279 bool changeddmap = false;
29280 if(currdmap != dmapID)
29281 {
29282 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
29283 changeddmap = true;
29284 }
29285 if(dlevel != DMaps[dmapID].level)
29286 {
29287 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
29288 changedlevel = true;
29289 }
29290 dlevel = DMaps[dmapID].level;
29291 currdmap = dmapID;
29292 if(changeddmap)
29293 {
29294 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
29295 }
29296 if(changedlevel)
29297 {
29298 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
29299 }
29300 currmap=DMaps[currdmap].map;
29301 init_dmap();
29302 update_subscreens(dmapID);
29303 loadfullpal();
29304 ringcolor(false);
29305 loadlvlpal(DMaps[currdmap].color);
29306 //lastentrance_dmap = currdmap;
29307 homescr = currscr = scrID + DMaps[currdmap].xoff;
29308 loadscr(0,currdmap,currscr,-1,overlay);
29309
29310 if((tmpscr->flags&fDARK) && !get_qr(qr_NEW_DARKROOM))
29311 {
29312 if(get_qr(qr_FADE))
29313 {
29314 interpolatedfade();
29315 }
29316 else
29317 {
29318 loadfadepal((DMaps[currdmap].color)*pdLEVEL+poFADE3);
29319 }
29320
29321 darkroom=naturaldark=true;
29322 }
29323 else
29324 {
29325 darkroom=naturaldark=false;
29326 }
29327
29328
29329 //Move Player's coordinates
29330 Hero.x = (zfix)wx;
29331 Hero.y = (zfix)wy;
29332 //set his dir
29333 switch(heroFacesDir)
29334 {
29335 case up:
29336 case down:
29337 case left:
29338 case right:
29339 Hero.dir = heroFacesDir;
29340 break;
29341 default:
29342 Hero.dir=down;
29343 if((int32_t)Hero.x==(zfix)0)
29344 {
29345 Hero.dir=right;
29346 }
29347 if((int32_t)Hero.x==(zfix)240)
29348 {
29349 Hero.dir=left;
29350 }
29351
29352 if((int32_t)Hero.y==(zfix)0)
29353 {
29354 Hero.dir=down;
29355 }
29356
29357 if((int32_t)Hero.y==(zfix)160)
29358 {
29359 Hero.dir=up;
29360 }
29361 }
29362
29363 if(dlevel)
29364 {
29365 // reset enemy kill counts
29366 for(int32_t i=0; i<128; i++)
29367 {
29368 game->guys[(currmap*MAPSCRSNORMAL)+i] = 0;
29369 game->maps[(currmap*MAPSCRSNORMAL)+i] &= ~mTMPNORET;
29370 }
29371 }
29372
29373 markBmap(Hero.dir^1);
29374 //preloaded freeform combos
29375 ffscript_engine(true);
29376 Hero.reset_hookshot();
29377
29378 if(isdungeon())
29379 {
29380 openscreen();
29381 if(get_er(er_SHORTDGNWALK)==0 && get_qr(qr_SHORTDGNWALK)==0)
29382 Hero.stepforward(Hero.diagonalMovement?11:12, false);
29383 else
29384 // Didn't walk as far pre-1.93, and some quests depend on that
29385 Hero.stepforward(8, false);
29386 }
29387 else
29388 {
29389 openscreen();
29390 }
29391
29392 show_subscreen_life=true;
29393 show_subscreen_numbers=true;
29394 Play_Level_Music();
29395 currcset=DMaps[currdmap].color;
29396 dointro();
29397 Hero.set_respawn_point();
29398 Hero.trySideviewLadder();
29399
29400 for(int32_t i=0; i<6; i++)
29401 visited[i]=-1;
29402
29403 //last_entr_scr = scrID;
29404 //last_entr_dmap = dmapID;
29405
29406 break;
29407
29408 }
29409 case wtSCROLL: // scrolling warp
29410 {
29411 int32_t c = DMaps[currdmap].color;
29412 scrolling_map = currmap;
29413 currmap = DMaps[dmapID].map;
29414 update_subscreens(dmapID);
29415
29416 dlevel = DMaps[dmapID].level;
29417 //check if Hero has the map for the new location before updating the subscreen. ? -Z
29418 //This works only in one direction, if Hero had a map, to not having one.
29419 //If Hero does not have a map, and warps somewhere where he does, then the map still briefly shows.
29420 update_subscreens(dmapID);
29421
29422 // if ( has_item(itype_map, dlevel) )
29423 // {
29424 // //Blank the map during an intra-dmap scrolling warp.
29425 // dlevel = -1; //a hack for the minimap. This works!! -Z
29426 // }
29427
29428 // fix the scrolling direction, if it was a tile or instant warp
29429 Hero.sdir = vbound(Hero.dir,0,3);
29430
29431
29432 Hero.scrollscr(Hero.sdir, scrID+DMaps[dmapID].xoff, dmapID);
29433 bool changedlevel = false;
29434 bool changeddmap = false;
29435 if(currdmap != dmapID)
29436 {
29437 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
29438 changeddmap = true;
29439 }
29440 if(dlevel != DMaps[dmapID].level)
29441 {
29442 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
29443 changedlevel = true;
29444 }
29445 dlevel = DMaps[dmapID].level;
29446 currdmap = dmapID;
29447 if(changeddmap)
29448 {
29449 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
29450 }
29451 if(changedlevel)
29452 {
29453 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
29454 }
29455
29456 Hero.reset_hookshot();
29457
29458 if(!intradmap)
29459 {
29460 currdmap = dmapID;
29461 dlevel = DMaps[currdmap].level;
29462 homescr = currscr = scrID + DMaps[dmapID].xoff;
29463 init_dmap();
29464
29465
29466 if(((wx>0||wy>0)||(get_qr(qr_WARPSIGNOREARRIVALPOINT)))&&(!get_qr(qr_NOSCROLLCONTINUE))&&(!(tmpscr->flags6&fNOCONTINUEHERE)))
29467 {
29468 if(dlevel)
29469 {
29470 lastentrance = currscr;
29471 }
29472 else
29473 {
29474 lastentrance = DMaps[currdmap].cont + DMaps[currdmap].xoff;
29475 }
29476
29477 lastentrance_dmap = dmapID;
29478 }
29479 }
29480
29481 if(DMaps[currdmap].color != c)
29482 {
29483 lighting(false, true);
29484 }
29485
29486 Play_Level_Music();
29487 currcset=DMaps[currdmap].color;
29488 dointro();
29489 break;
29490 }
29491 //Cannot use these types with scripts, or with strings.
29492 case wtCAVE:
29493 case wtPASS:
29494 case wtWHISTLE:
29495 default:
29496 {
29497 Z_scripterrlog("Invalid warp type (%d) supplied to Hero->WarpEx()!. Cannot warp!!\n", warpType);
29498 Hero.is_warping = false;
29499 return false;
29500 }
29501 }
29502 // Stop Hero from drowning!
29503
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(Hero.getAction()==drowning)
29504 {
29505 Hero.drownclk=0;
29506 Hero.setAction(none); FFCore.setHeroAction(none);
29507 }
29508
29509 // But keep him swimming if he ought to be!
29510
3/8
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 16 times.
✗ Branch 7 not taken.
16 if(Hero.getAction()!=rafting && iswaterex(MAPCOMBO((int32_t)Hero.x,(int32_t)Hero.y+8), currmap, currscr, -1, Hero.x, Hero.y+8, true) && (_walkflag((int32_t)Hero.x,(int32_t)Hero.y+8,0) || get_qr(qr_DROWN))
29511 && (current_item(itype_flippers)) && (Hero.getAction()!=inwind))
29512 {
29513 Hero.hopclk=0xFF;
29514 if (isSideViewHero() && get_qr(qr_SIDESWIM)) {Hero.setAction(sideswimming); FFCore.setHeroAction(sideswimming);}
29515 else {Hero.setAction(swimming); FFCore.setHeroAction(swimming);}
29516 }
29517
29518 16 newscr_clk=frame;
29519 16 activated_timed_warp=false;
29520 16 eat_buttons();
29521
29522
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(warpType!=wtIWARP) { Hero.attackclk=0; }
29523
29524 16 Hero.didstuff=0;
29525 16 Hero.usecounts.clear();
29526 16 map_bkgsfx(true);
29527 16 loadside=Hero.dir^1;
29528 16 whistleclk=-1;
29529
29530
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
16 if(((int32_t)Hero.z>0 || (int32_t)Hero.fakez>0) && isSideViewHero())
29531 {
29532 Hero.y-=Hero.z;
29533 Hero.y-=Hero.fakez;
29534 Hero.z=0;
29535 Hero.fakez=0;
29536 }
29537
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 else if(!isSideViewHero())
29538 {
29539 16 Hero.fall=0;
29540 16 Hero.fakefall=0;
29541 16 }
29542
29543 // If warping between top-down and sideview screens,
29544 // fix enemies that are carried over by Full Screen Warp
29545 16 const bool tmpscr_is_sideview = isSideViewGravity();
29546
29547
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
16 if(!wasSideview && tmpscr_is_sideview)
29548 {
29549 for(int32_t i=0; i<guys.Count(); i++)
29550 {
29551 if(guys.spr(i)->z > 0)
29552 {
29553 guys.spr(i)->y -= guys.spr(i)->z;
29554 guys.spr(i)->z = 0;
29555 }
29556
29557 if(((enemy*)guys.spr(i))->family!=eeTRAP && ((enemy*)guys.spr(i))->family!=eeSPINTILE)
29558 guys.spr(i)->yofs += 2;
29559 }
29560 }
29561
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16 else if(wasSideview && !tmpscr_is_sideview)
29562 {
29563 for(int32_t i=0; i<guys.Count(); i++)
29564 {
29565 if(((enemy*)guys.spr(i))->family!=eeTRAP && ((enemy*)guys.spr(i))->family!=eeSPINTILE)
29566 guys.spr(i)->yofs -= 2;
29567 }
29568 }
29569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( warpType == wtEXIT )
29570 {
29571 //game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
29572 game->set_continue_scrn(scrID);
29573 game->set_continue_dmap(dmapID);
29574 lastentrance = scrID;
29575 //zprint("Setting Last Entrance to: %d\n", scrID);
29576 //zprint("lastentrance = %d\n",lastentrance);
29577 lastentrance_dmap = dmapID;
29578 //zprint("Setting Last Entrance DMap to: %d\n", dmapID);
29579 //zprint("lastentrance_dmap = %d\n",lastentrance_dmap);
29580 //lastentrance_dmap = currdmap;
29581 //lastentrance = game->get_continue_scrn();
29582 }
29583 else
29584 {
29585
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if ( (warpFlags&warpFlagSETENTRANCESCREEN) ) lastentrance = scrID;
29586
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if ( (warpFlags&warpFlagSETENTRANCEDMAP) ) lastentrance_dmap = dmapID;
29587
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if ( (warpFlags&warpFlagSETCONTINUESCREEN) ) game->set_continue_scrn(scrID);
29588
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if ( (warpFlags&warpFlagSETCONTINUEDMAP) ) game->set_continue_dmap(dmapID);
29589
29590
29591 }
29592
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tmpscr->flags4&fAUTOSAVE)
29593 {
29594 save_game(true,0);
29595 }
29596
29597
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tmpscr->flags6&fCONTINUEHERE)
29598 {
29599 lastentrance_dmap = currdmap;
29600 lastentrance = homescr;
29601 }
29602
29603 16 update_subscreens();
29604 16 verifyBothWeapons();
29605 32 Z_eventlog("Warped to DMap %d: %s, screen %d, via %s.\n", currdmap, DMaps[currdmap].name,currscr,
29606
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
32 warpType==wtEXIT ? "Entrance/Exit" :
29607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 warpType==wtSCROLL ? "Scrolling Warp" :
29608 16 warpType==wtNOWARP ? "Cancel Warp" :
29609 "Insta-Warp");
29610
29611 16 eventlog_mapflags();
29612
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16 if (((warpFlags&warpFlagDONTRESTARTDMAPSCRIPT) != 0) == (get_qr(qr_SCRIPT_WARPS_DMAP_SCRIPT_TOGGLE) != 0)|| olddmap != currdmap) //Changed DMaps, or needs to reset the script
29613 {
29614 16 FFScript::deallocateAllArrays(ScriptType::DMap, olddmap);
29615 16 initZScriptDMapScripts();
29616 16 }
29617 16 Hero.is_warping = false;
29618
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!get_qr(qr_SCROLLWARP_NO_RESET_FRAME))
29619 GameFlags |= GAMEFLAG_RESET_GAME_LOOP;
29620 16 return true;
29621 16 }
29622
29623 void FFScript::do_adjustvolume(const bool v)
29624 {
29625 if (get_qr(qr_OLD_SCRIPT_VOLUME))
29626 {
29627 int32_t perc = (SH::get_arg(sarg1, v) / 10000);
29628 float pct = perc / 100.0;
29629 // zprint("pct is: %f\n",pct);
29630 float temp_midi = 0;
29631 float temp_digi = 0;
29632 float temp_mus = 0;
29633 if (!(coreflags & FFCORE_SCRIPTED_MIDI_VOLUME))
29634 {
29635 // zprint("FFCORE_SCRIPTED_MIDI_VOLUME: wasn't set\n");
29636 temp_midi = do_getMIDI_volume();
29637 // zprint("temp_midi is %f\n", temp_midi);
29638 usr_midi_volume = do_getMIDI_volume();
29639 // zprint("usr_midi_volume stored as %d\n", usr_midi_volume);
29640 SetFFEngineFlag(FFCORE_SCRIPTED_MIDI_VOLUME, true);
29641 }
29642 else
29643 {
29644 temp_midi = (float)usr_midi_volume;
29645 }
29646 if (!(coreflags & FFCORE_SCRIPTED_DIGI_VOLUME))
29647 {
29648 temp_digi = do_getDIGI_volume();
29649 usr_digi_volume = do_getDIGI_volume();
29650 // zprint("usr_music_volume stored as %d\n", usr_digi_volume);
29651 SetFFEngineFlag(FFCORE_SCRIPTED_DIGI_VOLUME, true);
29652 }
29653 else
29654 {
29655 temp_digi = (float)usr_digi_volume;
29656 }
29657 if (!(coreflags & FFCORE_SCRIPTED_MUSIC_VOLUME))
29658 {
29659 temp_mus = do_getMusic_volume();
29660 usr_music_volume = do_getMusic_volume();
29661 // zprint("usr_music_volume stored as %d\n", usr_music_volume);
29662 SetFFEngineFlag(FFCORE_SCRIPTED_MUSIC_VOLUME, true);
29663 }
29664 else
29665 {
29666 temp_mus = (float)usr_music_volume;
29667 }
29668
29669 temp_midi *= pct;
29670 temp_digi *= pct;
29671 temp_mus *= pct;
29672 // zprint("temp_midi is: %f\n",temp_midi);
29673 // zprint("temp_digi is: %f\n",temp_digi);
29674 // zprint("temp_mus is: %f\n",temp_mus);
29675 do_setMIDI_volume((int32_t)temp_midi);
29676 do_setDIGI_volume((int32_t)temp_digi);
29677 do_setMusic_volume((int32_t)temp_mus);
29678 }
29679 else
29680 {
29681 int32_t perc = SH::get_arg(sarg1, v);
29682 FFCore.usr_music_volume = vbound(perc, 0, 10000 * 100);
29683
29684 if (zcmusic != NULL)
29685 {
29686 if (zcmusic->playing != ZCM_STOPPED)
29687 {
29688 int32_t temp_volume = emusic_volume;
29689 if (!get_qr(qr_OLD_SCRIPT_VOLUME))
29690 temp_volume = (emusic_volume * FFCore.usr_music_volume) / 10000 / 100;
29691 temp_volume = (temp_volume * zcmusic->fadevolume) / 10000;
29692 zcmusic_play(zcmusic, temp_volume);
29693 return;
29694 }
29695 }
29696 else if (currmidi > -1)
29697 {
29698 jukebox(currmidi);
29699 master_volume(digi_volume, midi_volume);
29700 }
29701 }
29702 }
29703
29704 void FFScript::do_adjustsfxvolume(const bool v)
29705 {
29706 if (get_qr(qr_OLD_SCRIPT_VOLUME))
29707 {
29708 int32_t perc = (SH::get_arg(sarg1, v) / 10000);
29709 float pct = perc / 100.0;
29710 float temp_sfx = 0;
29711 if (!(coreflags & FFCORE_SCRIPTED_SFX_VOLUME))
29712 {
29713 temp_sfx = do_getSFX_volume();
29714 usr_sfx_volume = (int32_t)temp_sfx;
29715 // zprint("usr_sfx_volume stored as %d\n", usr_sfx_volume);
29716 SetFFEngineFlag(FFCORE_SCRIPTED_SFX_VOLUME, true);
29717 }
29718 else
29719 {
29720 temp_sfx = (float)usr_sfx_volume;
29721 }
29722 temp_sfx *= pct;
29723 do_setSFX_volume((int32_t)temp_sfx);
29724 }
29725 else
29726 {
29727 int32_t perc = SH::get_arg(sarg1, v);
29728 FFCore.usr_sfx_volume = vbound(perc, 0, 10000 * 100);
29729 }
29730 }
29731
29732
29733 63813 void do_midi(bool v)
29734 {
29735 63813 int32_t MIDI = SH::get_arg(sarg1, v) / 10000;
29736
29737
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 63776 times.
63813 if(MIDI == 0)
29738 37 music_stop();
29739 else
29740 63776 jukebox(MIDI + (ZC_MIDI_COUNT - 1));
29741 63813 }
29742
29743
29744 void stop_sfx(const bool v)
29745 {
29746 int32_t ID = SH::get_arg(sarg1, v) / 10000;
29747 int32_t sfx = (int32_t)ID;
29748 if(BC::checkSFXID(ID, "Game->EndSound") != SH::_NoError)
29749 return;
29750 stop_sfx(sfx);
29751 }
29752
29753 void pause_sfx(const bool v)
29754 {
29755 int32_t ID = SH::get_arg(sarg1, v) / 10000;
29756 int32_t sfx = (int32_t)ID;
29757 if(BC::checkSFXID(ID, "Game->PauseSound") != SH::_NoError)
29758 return;
29759 pause_sfx(sfx);
29760 }
29761
29762 void resume_sfx(const bool v)
29763 {
29764 int32_t ID = SH::get_arg(sarg1, v) / 10000;
29765 int32_t sfx = (int32_t)ID;
29766 if(BC::checkSFXID(ID, "Game->ResumeSound") != SH::_NoError)
29767 return;
29768 resume_sfx(sfx);
29769 }
29770
29771
29772
29773 79 void do_enh_music(bool v)
29774 {
29775 79 int32_t arrayptr = SH::get_arg(sarg1, v) / 10000;
29776 79 int32_t track = (SH::get_arg(sarg2, v) / 10000)-1;
29777
29778
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if(arrayptr == 0)
29779 music_stop();
29780 else // Pointer to a string..
29781 {
29782 79 string filename_str;
29783 char filename_char[256];
29784 bool ret;
29785
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 ArrayH::getString(arrayptr, filename_str, 256);
29786 79 strncpy(filename_char, filename_str.c_str(), 255);
29787 79 filename_char[255]='\0';
29788
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 ret=try_zcmusic(filename_char, track, -1000);
29789
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 set_register(sarg2, ret ? 10000 : 0);
29790 79 }
29791 79 }
29792
29793 void do_enh_music_crossfade()
29794 {
29795 int32_t arrayptr = SH::read_stack(ri->sp + 5) / 10000;
29796 int32_t track = SH::read_stack(ri->sp + 4) / 10000;
29797 int32_t fadeoutframes = zc_max(SH::read_stack(ri->sp + 3) / 10000, 0);
29798 int32_t fadeinframes = zc_max(SH::read_stack(ri->sp + 2) / 10000, 0);
29799 int32_t fademiddleframes = SH::read_stack(ri->sp + 1) / 10000;
29800 int32_t startpos = SH::read_stack(ri->sp);
29801
29802 if (arrayptr == 0)
29803 {
29804 bool ret = FFCore.play_enh_music_crossfade(NULL, track, fadeoutframes, fadeinframes, fademiddleframes, startpos);
29805 ri->d[rEXP1] = ret ? 10000 : 0;
29806 }
29807 else
29808 {
29809 string filename_str;
29810 char filename_char[256];
29811 ArrayH::getString(arrayptr, filename_str, 256);
29812 strncpy(filename_char, filename_str.c_str(), 255);
29813 filename_char[255] = '\0';
29814 bool ret = FFCore.play_enh_music_crossfade(filename_char, track, fadeoutframes, fadeinframes, fademiddleframes, startpos, true);
29815 ri->d[rEXP1] = ret ? 10000 : 0;
29816 }
29817 }
29818
29819 bool FFScript::play_enh_music_crossfade(char* name, int32_t track, int32_t fadeinframes, int32_t fadeoutframes, int32_t fademiddleframes, int32_t startpos, bool revertonfail)
29820 {
29821 double fadeoutpct = 1.0;
29822 // If there was an old fade going, use that as a multiplier for the new fade out
29823 if (zcmixer->newtrack != NULL)
29824 {
29825 fadeoutpct = double(zcmixer->newtrack->fadevolume) / 10000.0;
29826 }
29827
29828 ZCMUSIC* oldold = zcmixer->oldtrack;
29829 bool ret = false;
29830
29831 if (name == NULL)
29832 {
29833 // Pass currently playing music off to the mixer
29834 zcmixer->oldtrack = zcmusic;
29835 // Do not play new music
29836 zcmusic = NULL;
29837 zcmixer->newtrack = NULL;
29838
29839 zcmixer->fadeinframes = fadeinframes;
29840 zcmixer->fadeinmaxframes = fadeinframes;
29841 zcmixer->fadeoutframes = zc_max(fadeoutframes * fadeoutpct, 1);
29842 zcmixer->fadeoutmaxframes = fadeoutframes;
29843 if (fademiddleframes < 0)
29844 {
29845 zcmixer->fadeindelay = 0;
29846 zcmixer->fadeoutdelay = -fademiddleframes;
29847 }
29848 else
29849 {
29850 zcmixer->fadeindelay = fademiddleframes;
29851 zcmixer->fadeoutdelay = 0;
29852 }
29853 if (zcmixer->oldtrack != NULL)
29854 zcmixer->oldtrack->fadevolume = 10000;
29855 if (zcmixer->newtrack != NULL)
29856 zcmixer->newtrack->fadevolume = 0;
29857 }
29858 else // Pointer to a string..
29859 {
29860 // Pass currently playing music to the mixer
29861 zcmixer->oldtrack = zcmusic;
29862 zcmusic = NULL;
29863 zcmixer->newtrack = NULL;
29864
29865 ret = try_zcmusic(name, track, -1000, fadeoutframes);
29866 // If new music was found
29867 if (ret)
29868 {
29869 // New music fades in
29870 if (zcmusic != NULL)
29871 zcmusic->fadevolume = 0;
29872
29873 zcmixer->newtrack = zcmusic;
29874 zcmixer->fadeinframes = fadeinframes;
29875 zcmixer->fadeinmaxframes = fadeinframes;
29876 zcmixer->fadeoutframes = zc_max(fadeoutframes * fadeoutpct, 1);
29877 zcmixer->fadeoutmaxframes = fadeoutframes;
29878 if (fademiddleframes < 0)
29879 {
29880 zcmixer->fadeindelay = 0;
29881 zcmixer->fadeoutdelay = -fademiddleframes;
29882 }
29883 else
29884 {
29885 zcmixer->fadeindelay = fademiddleframes;
29886 zcmixer->fadeoutdelay = 0;
29887 }
29888 if (startpos > 0)
29889 zcmusic_set_curpos(zcmixer->newtrack, startpos);
29890 if (zcmixer->oldtrack != NULL)
29891 zcmixer->oldtrack->fadevolume = 10000;
29892 if (zcmixer->newtrack != NULL)
29893 zcmixer->newtrack->fadevolume = 0;
29894 }
29895 else if(revertonfail)
29896 {
29897 // Switch back to the old music
29898 zcmusic = zcmixer->oldtrack;
29899 zcmixer->newtrack = NULL;
29900 zcmixer->oldtrack = NULL;
29901 }
29902 }
29903
29904 // If there was already an old track playing, stop it
29905 if (oldold != NULL)
29906 {
29907 // Don't allow it to null both tracks if running twice in a row
29908 if (zcmixer->newtrack == NULL && zcmixer->oldtrack == NULL)
29909 {
29910 zcmixer->oldtrack = oldold;
29911
29912 if (oldold->fadeoutframes > 0)
29913 {
29914 zcmixer->fadeoutframes = zc_max(oldold->fadeoutframes * fadeoutpct, 1);
29915 zcmixer->fadeoutmaxframes = oldold->fadeoutframes;
29916 if (zcmixer->oldtrack != NULL)
29917 zcmixer->oldtrack->fadevolume = 10000;
29918 oldold->fadeoutframes = 0;
29919 }
29920 }
29921 else
29922 {
29923 zcmusic_stop(oldold);
29924 zcmusic_unload_file(oldold);
29925 oldold = NULL;
29926 }
29927 }
29928
29929 return ret;
29930 }
29931
29932 bool FFScript::doing_dmap_enh_music(int32_t dm)
29933 {
29934 if (DMaps[dm].tmusic[0] != 0)
29935 {
29936 if (zcmusic != NULL)
29937 {
29938 if (strcmp(zcmusic->filename, DMaps[dm].tmusic) == 0)
29939 {
29940 switch (zcmusic_get_type(zcmusic))
29941 {
29942 case ZCMF_OGG:
29943 case ZCMF_MP3:
29944 return true;
29945 case ZCMF_DUH:
29946 case ZCMF_GME:
29947 if (zcmusic->track == DMaps[dm].tmusictrack)
29948 {
29949 return true;
29950 }
29951 }
29952 }
29953 }
29954 }
29955 return false;
29956 }
29957
29958 17605 bool FFScript::can_dmap_change_music(int32_t dm)
29959 {
29960
1/4
✓ Branch 0 taken 17605 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
17605 switch (music_update_cond)
29961 {
29962 case MUSIC_UPDATE_SCREEN:
29963 17605 return true;
29964 case MUSIC_UPDATE_DMAP:
29965 return dm != -1 && dm != currdmap;
29966 case MUSIC_UPDATE_LEVEL:
29967 return dm != -1 && DMaps[dm].level != DMaps[currdmap].level;
29968 }
29969 return false;
29970 17605 }
29971
29972 void FFScript::do_set_music_position(const bool v)
29973 {
29974 int32_t newposition = SH::get_arg(sarg1, v);
29975
29976 set_zcmusicpos(newposition);
29977 }
29978
29979 void FFScript::do_get_music_position()
29980 {
29981 int32_t pos = replay_get_state(ReplayStateType::MusicPosition, [](){
29982 return zcmusic_get_curpos(zcmusic);
29983 });
29984 set_register(sarg1, pos);
29985 }
29986
29987 void FFScript::do_set_music_speed(const bool v)
29988 {
29989 int32_t newspeed = SH::get_arg(sarg1, v);
29990 set_zcmusicspeed(newspeed);
29991 }
29992
29993 void FFScript::do_get_music_length()
29994 {
29995 int32_t len = get_zcmusiclen();
29996 set_register(sarg1, len);
29997 }
29998
29999 void FFScript::do_set_music_loop()
30000 {
30001 double start = (get_register(sarg1) / 10000);
30002 double end = (get_register(sarg2) / 10000);
30003
30004 set_zcmusicloop(start, end);
30005 }
30006
30007 100 void do_get_enh_music_filename(const bool v)
30008 {
30009 100 int32_t ID = SH::get_arg(sarg1, v) / 10000;
30010 100 int32_t arrayptr = get_register(sarg2) / 10000;
30011
30012
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(BC::checkDMapID(ID, "Game->GetDMapMusicFilename") != SH::_NoError)
30013 return;
30014
30015
3/6
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 100 times.
✗ Branch 5 not taken.
100 if(ArrayH::setArray(arrayptr, string(DMaps[ID].tmusic)) == SH::_Overflow)
30016 Z_scripterrlog("Array supplied to 'Game->GetDMapMusicFilename' not large enough\n");
30017 100 }
30018
30019 5 void do_get_enh_music_track(const bool v)
30020 {
30021 5 int32_t ID = SH::get_arg(sarg1, v) / 10000;
30022
30023
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(BC::checkDMapID(ID, "Game->GetDMapMusicTrack") != SH::_NoError)
30024 return;
30025
30026 5 set_register(sarg1, (DMaps[ID].tmusictrack+1)*10000);
30027 5 }
30028
30029 3750 void do_set_dmap_enh_music(const bool v)
30030 {
30031 3750 int32_t ID = SH::read_stack(ri->sp + 2) / 10000;
30032 3750 int32_t arrayptr = SH::read_stack(ri->sp + 1) / 10000;
30033 3750 int32_t track = (SH::read_stack(ri->sp + 0) / 10000)-1;
30034 3750 string filename_str;
30035
30036
2/4
✓ Branch 0 taken 3750 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3750 times.
✗ Branch 3 not taken.
3750 if(BC::checkDMapID(ID, "Game->SetDMapEnhancedMusic") != SH::_NoError)
30037 return;
30038
30039
1/2
✓ Branch 0 taken 3750 times.
✗ Branch 1 not taken.
3750 ArrayH::getString(arrayptr, filename_str, 56);
30040 3750 strncpy(DMaps[ID].tmusic, filename_str.c_str(), 55);
30041 3750 DMaps[ID].tmusic[55]='\0';
30042 3750 DMaps[ID].tmusictrack=track;
30043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3750 times.
3750 }
30044
30045
30046
30047
30048
30049
30050 ///----------------------------------------------------------------------------------------------------//
30051 //Array & string related
30052
30053 294114397 void do_arraysize()
30054 {
30055 294114397 int32_t arrayptr = get_register(sarg1) / 10000;
30056 294114397 ri->d[rEXP1] = ArrayH::getSize(arrayptr) * 10000;
30057 294114397 }
30058
30059 void do_tobyte()
30060 {
30061 int32_t b1 = get_register(sarg1) / 10000;
30062 byte b2 = b1;
30063 set_register(sarg1, b2 * 10000);
30064 }
30065
30066 void do_tosignedbyte()
30067 {
30068 int32_t b1 = get_register(sarg1) / 10000;
30069 signed char b2 = b1;
30070 set_register(sarg1, b2 * 10000);
30071 }
30072
30073 void do_tointeger()
30074 {
30075 int32_t b1 = get_register(sarg1) / 10000;
30076 set_register(sarg1, b1 * 10000);
30077 }
30078
30079 void do_floor()
30080 {
30081 double b1 = get_register(sarg1) / 10000.0;
30082 int32_t b2 = floor(b1);
30083 set_register(sarg1, b2 * 10000);
30084 }
30085
30086 void do_ceiling()
30087 {
30088 double b1 = get_register(sarg1) / 10000.0;
30089 int32_t b2 = ceil(b1);
30090 set_register(sarg1, b2 * 10000);
30091 }
30092
30093 void do_toword()
30094 {
30095 int32_t b1 = get_register(sarg1) / 10000;
30096 word b2 = b1;
30097 set_register(sarg1, b2 * 10000);
30098 }
30099
30100 void do_toshort()
30101 {
30102 int32_t b1 = get_register(sarg1) / 10000;
30103 int16_t b2 = b1;
30104 set_register(sarg1, b2 * 10000);
30105 }
30106
30107 10 void do_getsavename()
30108 {
30109 10 int32_t arrayptr = get_register(sarg1) / 10000;
30110
30111
3/6
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
10 if(ArrayH::setArray(arrayptr, string(game->get_name())) == SH::_Overflow)
30112 Z_scripterrlog("Array supplied to 'Game->GetSaveName' not large enough\n");
30113 10 }
30114
30115 void do_setsavename()
30116 {
30117 int32_t arrayptr = get_register(sarg1) / 10000;
30118
30119 string str;
30120 ArrayH::getString(arrayptr, str);
30121 byte j;
30122
30123 for(j = 0; str[j] != '\0'; j++)
30124 {
30125 if(j >= 8)
30126 {
30127 Z_scripterrlog("String supplied to 'Game->GetSaveName' too large\n");
30128 break;
30129 }
30130
30131 game->get_name_mutable()[j] = str[j];
30132 }
30133
30134 game->get_name_mutable()[j] = '\0';
30135 }
30136
30137 3666 void do_getmessage(const bool v)
30138 {
30139 3666 int32_t ID = SH::get_arg(sarg1, v) / 10000;
30140 3666 int32_t arrayptr = get_register(sarg2) / 10000;
30141
30142
1/2
✓ Branch 0 taken 3666 times.
✗ Branch 1 not taken.
3666 if(BC::checkMessage(ID, "Game->GetMessage") != SH::_NoError)
30143 return;
30144
30145
2/2
✓ Branch 0 taken 3618 times.
✓ Branch 1 taken 48 times.
3666 if(ArrayH::setArray(arrayptr, MsgStrings[ID].s) == SH::_Overflow)
30146 48 Z_scripterrlog("Array supplied to 'Game->GetMessage' not large enough\n");
30147 3666 }
30148
30149
30150
30151 void do_setmessage(const bool v)
30152 {
30153 int32_t ID = SH::get_arg(sarg1, v) / 10000;
30154 int32_t arrayptr = get_register(sarg2) / 10000;
30155
30156 if(BC::checkMessage(ID, "Game->SetMessage") != SH::_NoError)
30157 return;
30158
30159 ArrayH::getString(arrayptr, MsgStrings[ID].s, MSG_NEW_SIZE);
30160 }
30161
30162
30163 void do_getdmapname(const bool v)
30164 {
30165 int32_t ID = SH::get_arg(sarg1, v) / 10000;
30166 int32_t arrayptr = get_register(sarg2) / 10000;
30167
30168 if(BC::checkDMapID(ID, "Game->GetDMapName") != SH::_NoError)
30169 return;
30170
30171 if(ArrayH::setArray(arrayptr, string(DMaps[ID].name)) == SH::_Overflow)
30172 Z_scripterrlog("Array supplied to 'Game->GetDMapName' not large enough\n");
30173 }
30174
30175 void do_setdmapname(const bool v)
30176 {
30177 int32_t ID = SH::get_arg(sarg1, v) / 10000;
30178 int32_t arrayptr = get_register(sarg2) / 10000;
30179
30180 string filename_str;
30181
30182 if(BC::checkDMapID(ID, "Game->Game->SetDMapName") != SH::_NoError)
30183 return;
30184
30185 ArrayH::getString(arrayptr, filename_str, 22);
30186 strncpy(DMaps[ID].name, filename_str.c_str(), 21);
30187 DMaps[ID].name[20]='\0';
30188 }
30189
30190 void do_getdmaptitle(const bool v)
30191 {
30192 int32_t ID = SH::get_arg(sarg1, v) / 10000;
30193 int32_t arrayptr = get_register(sarg2) / 10000;
30194
30195 if(BC::checkDMapID(ID, "Game->GetDMapTitle") != SH::_NoError)
30196 return;
30197
30198 if(ArrayH::setArray(arrayptr, string(DMaps[ID].title)) == SH::_Overflow)
30199 Z_scripterrlog("Array supplied to 'Game->GetDMapTitle' not large enough\n");
30200 }
30201
30202
30203 void do_setdmaptitle(const bool v)
30204 {
30205 int32_t ID = SH::get_arg(sarg1, v) / 10000;
30206 int32_t arrayptr = get_register(sarg2) / 10000;
30207 string filename_str;
30208
30209 if(BC::checkDMapID(ID, "Game->Game->SetDMapTitle") != SH::_NoError)
30210 return;
30211
30212 ArrayH::getString(arrayptr, filename_str, 21);
30213 strncpy(DMaps[ID].title, filename_str.c_str(), 20);
30214 DMaps[ID].title[20]='\0';
30215 }
30216
30217 void do_getdmapintro(const bool v)
30218 {
30219 int32_t ID = SH::get_arg(sarg1, v) / 10000;
30220 int32_t arrayptr = get_register(sarg2) / 10000;
30221
30222 if(BC::checkDMapID(ID, "Game->GetDMapIntro") != SH::_NoError)
30223 return;
30224
30225 if(ArrayH::setArray(arrayptr, string(DMaps[ID].intro)) == SH::_Overflow)
30226 Z_scripterrlog("Array supplied to 'Game->GetDMapIntro' not large enough\n");
30227 }
30228
30229
30230 void do_setdmapintro(const bool v)
30231 {
30232 int32_t ID = SH::get_arg(sarg1, v) / 10000;
30233 int32_t arrayptr = get_register(sarg2) / 10000;
30234 string filename_str;
30235
30236 if(BC::checkDMapID(ID, "Game->Game->SetDMapIntro") != SH::_NoError)
30237 return;
30238
30239 ArrayH::getString(arrayptr, filename_str, 73);
30240 strncpy(DMaps[ID].intro, filename_str.c_str(), 72);
30241 DMaps[ID].intro[72]='\0';
30242 }
30243
30244 //Set npc and item names t.b.a. -Z
30245
30246 2567 void do_getitemname()
30247 {
30248 2567 int32_t arrayptr = get_register(sarg1) / 10000;
30249
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2567 times.
2567 if(unsigned(ri->idata) >= MAXITEMS)
30250 {
30251 Z_scripterrlog("Invalid itemdata access: %d\n", ri->idata);
30252 return;
30253 }
30254
30255
3/6
✓ Branch 0 taken 2567 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2567 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2567 times.
✗ Branch 5 not taken.
2567 if(ArrayH::setArray(arrayptr, item_string[ri->idata]) == SH::_Overflow)
30256 Z_scripterrlog("Array supplied to 'itemdata->GetName' not large enough\n");
30257 2567 }
30258
30259 void do_getnpcname()
30260 {
30261 int32_t arrayptr = get_register(sarg1) / 10000;
30262
30263 if(GuyH::loadNPC(ri->guyref, "npc->GetName") != SH::_NoError)
30264 return;
30265
30266 word ID = (GuyH::getNPC()->id & 0xFFF);
30267
30268 if(ArrayH::setArray(arrayptr, guy_string[ID]) == SH::_Overflow)
30269 Z_scripterrlog("Array supplied to 'npc->GetName' not large enough\n");
30270 }
30271
30272 //npcdata->GetName
30273 void FFScript::do_getnpcdata_getname()
30274 {
30275 int32_t arrayptr = get_register(sarg1) / 10000;
30276 int32_t npc_id = ri->npcdataref;
30277 if((unsigned)npc_id > 511)
30278 {
30279 Z_scripterrlog("Invalid npc ID (%d) passed to npcdata->GetName().\n", npc_id);
30280 return;
30281 }
30282
30283 if(ArrayH::setArray(arrayptr, guy_string[npc_id]) == SH::_Overflow)
30284 Z_scripterrlog("Array supplied to 'npcdata->GetName()' not large enough\n");
30285 }
30286
30287 227724 void do_getffcscript()
30288 {
30289 227724 int32_t arrayptr = get_register(sarg1) / 10000;
30290 227724 string name;
30291 227724 int32_t num=-1;
30292
1/2
✓ Branch 0 taken 227724 times.
✗ Branch 1 not taken.
227724 ArrayH::getString(arrayptr, name, 256); // What's the limit on name length?
30293
30294
2/2
✓ Branch 0 taken 116286088 times.
✓ Branch 1 taken 227034 times.
116513122 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
30295 {
30296
3/4
✓ Branch 0 taken 116286088 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116285398 times.
✓ Branch 3 taken 690 times.
116286088 if(strcmp(name.c_str(), ffcmap[i].scriptname.c_str())==0)
30297 {
30298 690 num=i+1;
30299 690 break;
30300 }
30301 116285398 }
30302
30303
1/2
✓ Branch 0 taken 227724 times.
✗ Branch 1 not taken.
227724 set_register(sarg1, num * 10000);
30304 227724 }
30305
30306 void do_npc_hero_in_range()
30307 {
30308 int32_t dist = get_register(sarg1) / 10000;
30309 if(GuyH::loadNPC(ri->guyref, "npc->LinedUp()") == SH::_NoError)
30310 {
30311 bool in_range = GuyH::getNPC()->HeroInRange(dist);
30312 set_register(sarg1, 0);
30313 }
30314 else set_register(sarg1, 0);
30315 }
30316
30317 80 void do_getitemscript()
30318 {
30319 80 int32_t arrayptr = get_register(sarg1) / 10000;
30320 80 string name;
30321 80 int32_t num=-1;
30322
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 ArrayH::getString(arrayptr, name, 256); // What's the limit on name length?
30323
30324
1/2
✓ Branch 0 taken 2360 times.
✗ Branch 1 not taken.
2360 for(int32_t i=0; i<512; i++)
30325 {
30326
3/4
✓ Branch 0 taken 2360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2280 times.
✓ Branch 3 taken 80 times.
2360 if(strcmp(name.c_str(), itemmap[i].scriptname.c_str())==0)
30327 {
30328 80 num=i+1;
30329 80 break;
30330 }
30331 2280 }
30332
30333
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 set_register(sarg1, num * 10000);
30334 80 }
30335
30336 ///----------------------------------------------------------------------------------------------------//
30337 //Tile Manipulation
30338
30339 16962076 void do_copytile(const bool v, const bool v2)
30340 {
30341 16962076 int32_t tile = SH::get_arg(sarg1, v) / 10000;
30342 16962076 int32_t tile2 = SH::get_arg(sarg2, v2) / 10000;
30343
30344 16962076 copy_tile(newtilebuf, tile, tile2, false);
30345 16962076 }
30346
30347 int32_t FFScript::IsBlankTile(int32_t i)
30348 {
30349 if( ((unsigned)i) > NEWMAXTILES )
30350 {
30351 Z_scripterrlog("Invalid tile ID (%d) passed to Graphics->IsBlankTile[]\n");
30352 return -1;
30353 }
30354
30355 byte *tilestart=newtilebuf[i].data;
30356 qword *di=(qword*)tilestart;
30357 int32_t parts=tilesize(newtilebuf[i].format)>>3;
30358
30359 for(int32_t j=0; j<parts; ++j, ++di)
30360 {
30361 if(*di!=0)
30362 {
30363 return 0;
30364 }
30365 }
30366
30367 return 1;
30368 }
30369
30370 void do_swaptile(const bool v, const bool v2)
30371 {
30372 int32_t tile = SH::get_arg(sarg1, v) / 10000;
30373 int32_t tile2 = SH::get_arg(sarg2, v2) / 10000;
30374
30375 copy_tile(newtilebuf, tile, tile2, true);
30376 }
30377
30378 57032 void do_overlaytile(const bool v, const bool v2)
30379 {
30380 57032 int32_t tile = SH::get_arg(sarg1, v) / 10000;
30381 57032 int32_t tile2 = SH::get_arg(sarg2, v2) / 10000;
30382
30383
2/4
✓ Branch 0 taken 57032 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57032 times.
✗ Branch 3 not taken.
57032 if(BC::checkTile(tile, "OverlayTile") != SH::_NoError ||
30384 57032 BC::checkTile(tile2, "OverlayTile") != SH::_NoError)
30385 return;
30386
30387 //Could add an arg for the CSet or something instead of just passing 0, currently only 8-bit is supported
30388 57032 overlay_tile(newtilebuf, tile, tile2, 0, false);
30389 57032 }
30390
30391 void do_fliprotatetile(const bool v, const bool v2)
30392 {
30393 int32_t tile = SH::get_arg(sarg1, v) / 10000;
30394 int32_t tile2 = SH::get_arg(sarg2, v2) / 10000;
30395
30396 if(BC::checkTile(tile, "FlipRotateTile") != SH::_NoError ||
30397 BC::checkTile(tile2, "FlipRotateTile") != SH::_NoError)
30398 return;
30399
30400 //fliprotatetile
30401 }
30402
30403 void do_settilepixel(const bool v)
30404 {
30405 int32_t tile = SH::get_arg(sarg1, v) / 10000;
30406
30407 if(BC::checkTile(tile, "SetTilePixel") != SH::_NoError)
30408 return;
30409
30410 //settilepixel
30411 }
30412
30413 void do_gettilepixel(const bool v)
30414 {
30415 int32_t tile = SH::get_arg(sarg1, v) / 10000;
30416
30417 if(BC::checkTile(tile, "GetTilePixel") != SH::_NoError)
30418 return;
30419
30420 //gettilepixel
30421 }
30422
30423 void do_shifttile(const bool v, const bool v2)
30424 {
30425 int32_t tile = SH::get_arg(sarg1, v) / 10000;
30426 int32_t tile2 = SH::get_arg(sarg2, v2) / 10000;
30427
30428 if(BC::checkTile(tile, "ShiftTile") != SH::_NoError ||
30429 BC::checkTile(tile2, "ShiftTile") != SH::_NoError)
30430 return;
30431
30432 //shifttile
30433 }
30434
30435 void do_cleartile(const bool v)
30436 {
30437 int32_t tile = SH::get_arg(sarg1, v) / 10000;
30438
30439 if(BC::checkTile(tile, "ClearTile") != SH::_NoError)
30440 return;
30441
30442 reset_tile(newtilebuf, tile, newtilebuf[tile].format);
30443 }
30444
30445 2564 void do_combotile(const bool v)
30446 {
30447 2564 int32_t combo = SH::get_arg(sarg2, v) / 10000;
30448
30449
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2564 times.
2564 if(BC::checkCombo(combo, "Game->ComboTile") != SH::_NoError)
30450 return;
30451
30452 2564 set_register(sarg1, combobuf[combo].tile * 10000);
30453 2564 }
30454
30455 94280302 void do_readpod(const bool v)
30456 {
30457 94280302 int32_t indx = SH::get_arg(sarg2, v) / 10000;
30458 94280302 int32_t val = ArrayH::getElement(ri->d[rINDEX] / 10000, indx, can_neg_array);
30459 94280302 set_register(sarg1, val);
30460 94280302 }
30461 63016494 void do_writepod(const bool v1, const bool v2)
30462 {
30463 63016494 int32_t indx = SH::get_arg(sarg1, v1) / 10000;
30464 63016494 int32_t val = SH::get_arg(sarg2, v2);
30465 63016494 ArrayH::setElement(ri->d[rINDEX] / 10000, indx, val, can_neg_array);
30466 63016494 }
30467 236289 void do_writepodstr()
30468 {
30469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 236289 times.
236289 if(!sargstr) return;
30470 236289 auto ptr = get_register(sarg1) / 10000;
30471 236289 ArrayH::setArray(ptr, *sargstr);
30472 236289 }
30473 302 void do_writepodarr()
30474 {
30475
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 302 times.
302 if(!sargvec) return;
30476 302 auto ptr = get_register(sarg1) / 10000;
30477 302 ArrayH::setArray(ptr, sargvec->size(), sargvec->data(), false);
30478 302 }
30479 int32_t get_object_arr(size_t sz)
30480 {
30481 if(!sz || sz > 214748) return 0;
30482 int32_t free_ptr = 1;
30483 auto it = objectRAM.begin();
30484 if(it != objectRAM.end())
30485 {
30486 if(it->first == 1)
30487 {
30488 for(free_ptr = 2; ; ++free_ptr)
30489 {
30490 if(objectRAM.find(free_ptr) == objectRAM.end())
30491 break;
30492 }
30493 }
30494 }
30495 ZScriptArray arr;
30496 arr.Resize(sz);
30497 objectRAM[free_ptr] = arr;
30498 // auto res = objectRAM.emplace(free_ptr);
30499 // ZScriptArray& arr = res.first->second;
30500 // arr.Resize(sz);
30501
30502 return -free_ptr;
30503 }
30504 void destroy_object_arr(int32_t ptr)
30505 {
30506 if(ptr < 0)
30507 {
30508 auto it = objectRAM.find(-ptr);
30509 if(it != objectRAM.end())
30510 objectRAM.erase(it);
30511 }
30512 }
30513 void do_constructclass(ScriptType type, word script, int32_t i)
30514 {
30515 if(!sargvec) return;
30516
30517 size_t num_vars = sargvec->at(0);
30518 size_t total_vars = num_vars + sargvec->size()-1;
30519 auto destr_pc = ri->d[rEXP1];
30520 dword objref = FFCore.get_free_object(false);
30521
30522 if(user_object* obj = checkObject(objref, true))
30523 {
30524 obj->own(type, i);
30525 obj->owned_vars = num_vars;
30526 for(size_t q = 0; q < total_vars; ++q)
30527 {
30528 if(q < num_vars)
30529 {
30530 obj->data.push_back(0);
30531 }
30532 else
30533 {
30534 size_t sz = sargvec->at(q-num_vars+1);
30535 if(auto id = get_object_arr(sz))
30536 obj->data.push_back(10000*id);
30537 else obj->data.push_back(0); //nullptr
30538 }
30539 }
30540 set_register(sarg1, objref);
30541 ri->thiskey = objref;
30542 obj->prep(destr_pc,type,script,i);
30543 }
30544 else set_register(sarg1, 0);
30545 }
30546
30547 void do_readclass()
30548 {
30549 dword objref = get_register(sarg1);
30550 ri->d[rEXP1] = 0;
30551 int32_t ind = sarg2;
30552 if(user_object* obj = checkObject(objref))
30553 {
30554 if(unsigned(ind) >= obj->data.size())
30555 {
30556 Z_scripterrlog("Script tried to read position '%d' out of bounds on a '%d' size object (%d).", ind, obj->data.size(), objref);
30557 }
30558 else
30559 {
30560 ri->d[rEXP1] = obj->data.at(ind);
30561 }
30562 }
30563 }
30564 void do_writeclass()
30565 {
30566 dword objref = get_register(sarg1);
30567 int32_t ind = sarg2;
30568 if(user_object* obj = checkObject(objref))
30569 {
30570 if(unsigned(ind) >= obj->data.size())
30571 {
30572 Z_scripterrlog("Script tried to write position '%d' out of bounds on a '%d' size object (%d).", ind, obj->data.size(), objref);
30573 }
30574 else
30575 {
30576 obj->data[ind] = ri->d[rEXP1];
30577 }
30578 }
30579 }
30580 void do_freeclass()
30581 {
30582 dword objref = get_register(sarg1);
30583 if(user_object* obj = checkObject(objref, true))
30584 {
30585 obj->clear();
30586 }
30587 ri->d[rEXP1] = 0;
30588 }
30589
30590 bool zasm_advance()
30591 {
30592 if( key[KEY_INSERT] )
30593 {
30594 if(key[KEY_LSHIFT] || key[KEY_RSHIFT])
30595 {
30596 if(key[KEY_LCONTROL] || key[KEY_RCONTROL])
30597 {
30598 FFCore.zasm_break_mode = ZASM_BREAK_SKIP_SCRIPT;
30599 }
30600 else FFCore.zasm_break_mode = ZASM_BREAK_ADVANCE_SCRIPT;
30601 }
30602 else if(key[KEY_ALT] || key[KEY_ALTGR])
30603 {
30604 if(key[KEY_LCONTROL] || key[KEY_RCONTROL])
30605 {
30606 FFCore.zasm_break_mode = ZASM_BREAK_SKIP;
30607 }
30608 else FFCore.zasm_break_mode = ZASM_BREAK_NONE;
30609 }
30610 else if(key[KEY_LCONTROL] || key[KEY_RCONTROL])
30611 {
30612 FFCore.ZASMPrint(false); //Close debugger
30613 FFCore.zasm_break_mode = ZASM_BREAK_NONE;
30614 }
30615 return true;
30616 }
30617 if(!zasm_debugger)
30618 {
30619 FFCore.zasm_break_mode = ZASM_BREAK_NONE;
30620 return true;
30621 }
30622 return false;
30623 }
30624
30625 int32_t get_own_i(ScriptType type)
30626 {
30627 switch(type)
30628 {
30629 case ScriptType::Lwpn:
30630 return ri->lwpn;
30631 case ScriptType::Ewpn:
30632 return ri->ewpn;
30633 case ScriptType::ItemSprite:
30634 return ri->itemref;
30635 case ScriptType::NPC:
30636 return ri->guyref;
30637 case ScriptType::FFC:
30638 return ri->ffcref;
30639 }
30640 return 0;
30641 }
30642
30643 portal* loadportal(savedportal& p);
30644 ///----------------------------------------------------------------------------------------------------//
30645 // Run the script //
30646 ///----------------------------------------------------------------------------------------------------//
30647
30648
30649 10293791 int32_t run_script(ScriptType type, const word script, const int32_t i)
30650 {
30651
2/4
✓ Branch 0 taken 10293791 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10293791 times.
10293791 if(Quit==qRESET || Quit==qEXIT) // In case an earlier script hung
30652 return RUNSCRIPT_ERROR;
30653
30654
4/4
✓ Branch 0 taken 6408421 times.
✓ Branch 1 taken 3885370 times.
✓ Branch 2 taken 5769843 times.
✓ Branch 3 taken 638578 times.
10293791 if(type != ScriptType::Global && !script) return RUNSCRIPT_OK; //Safeguard against running null scripts
30655
30656 9655213 combopos_modified = -1;
30657 9655213 curScriptType=type;
30658 9655213 curScriptNum=script;
30659 9655213 curScriptIndex=i;
30660 //numInstructions=0; //DON'T CLEAR THIS OR IT CAN HARDLOCK! -Em
30661
30662
2/4
✓ Branch 0 taken 9655213 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9655213 times.
9655213 if (!(type >= ScriptType::First && type <= ScriptType::Last))
30663 {
30664 al_trace("Invalid script type: %d\n", type);
30665 return RUNSCRIPT_ERROR;
30666 }
30667
30668 9655213 bool got_initialized = false;
30669
6/8
✓ Branch 0 taken 8914035 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 188480 times.
✓ Branch 4 taken 104554 times.
✓ Branch 5 taken 2517 times.
✓ Branch 6 taken 444085 times.
✓ Branch 7 taken 1542 times.
9655213 switch(type)
30670 {
30671 case ScriptType::FFC:
30672 case ScriptType::Global:
30673 case ScriptType::Player:
30674 case ScriptType::DMap:
30675 case ScriptType::OnMap:
30676 case ScriptType::ActiveSubscreen:
30677 case ScriptType::PassiveSubscreen:
30678 case ScriptType::Screen:
30679 case ScriptType::Combo:
30680 case ScriptType::Item:
30681 {
30682 // TODO: finish refactoring the other script types.
30683 8914035 got_initialized = set_current_script_engine_data(type, script, i);
30684 }
30685 8914035 break;
30686
30687 case ScriptType::NPC:
30688 {
30689 int32_t npc_index = GuyH::getNPCIndex(i);
30690 enemy *w = (enemy*)guys.spr(npc_index);
30691 ri = &(w->scrmem->scriptData);
30692 curscript = guyscripts[w->script];
30693 stack = &(w->scrmem->stack);
30694 ri->guyref = i;
30695
30696 if (!w->initialised)
30697 {
30698 got_initialized = true;
30699 for ( int32_t q = 0; q < 8; q++ )
30700 {
30701 ri->d[q] = w->initD[q];
30702 }
30703 w->initialised = 1;
30704 }
30705 }
30706 break;
30707
30708 case ScriptType::Lwpn:
30709 {
30710 188480 int32_t lwpn_index = LwpnH::getLWeaponIndex(i);
30711 188480 weapon *w = (weapon*)Lwpns.spr(lwpn_index);
30712 188480 ri = &(w->scrmem->scriptData);
30713 188480 curscript = lwpnscripts[w->weaponscript];
30714 188480 stack = &(w->scrmem->stack);
30715 188480 ri->lwpn = i;
30716
30717
2/2
✓ Branch 0 taken 61248 times.
✓ Branch 1 taken 127232 times.
188480 if (!w->initialised)
30718 {
30719 61248 got_initialized = true;
30720
2/2
✓ Branch 0 taken 489984 times.
✓ Branch 1 taken 61248 times.
551232 for ( int32_t q = 0; q < 8; q++ )
30721 {
30722 489984 ri->d[q] = w->weap_initd[q]; //w->initiald[q];
30723 489984 }
30724 61248 w->initialised = 1;
30725 61248 }
30726 }
30727 188480 break;
30728
30729 case ScriptType::Ewpn:
30730 {
30731 104554 int32_t ewpn_index = EwpnH::getEWeaponIndex(i);
30732 104554 weapon *w = (weapon*)Ewpns.spr(ewpn_index);
30733 104554 ri = &(w->scrmem->scriptData);
30734 104554 curscript = ewpnscripts[w->weaponscript];
30735 104554 stack = &(w->scrmem->stack);
30736 104554 ri->ewpn = i;
30737
30738
2/2
✓ Branch 0 taken 1275 times.
✓ Branch 1 taken 103279 times.
104554 if (!w->initialised)
30739 {
30740 1275 got_initialized = true;
30741
2/2
✓ Branch 0 taken 10200 times.
✓ Branch 1 taken 1275 times.
11475 for ( int32_t q = 0; q < 8; q++ )
30742 {
30743 10200 ri->d[q] = w->weap_initd[q];
30744 10200 }
30745 1275 w->initialised = 1;
30746 1275 }
30747 }
30748 104554 break;
30749
30750 case ScriptType::ItemSprite:
30751 {
30752 2517 int32_t the_index = ItemH::getItemIndex(i);
30753 2517 item *w = (item*)items.spr(the_index);
30754 2517 ri = &(w->scrmem->scriptData);
30755 2517 curscript = itemspritescripts[w->script];
30756 2517 stack = &(w->scrmem->stack);
30757 2517 ri->itemref = i;
30758
30759
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 2435 times.
2517 if (!w->initialised)
30760 {
30761 82 got_initialized = true;
30762
2/2
✓ Branch 0 taken 656 times.
✓ Branch 1 taken 82 times.
738 for ( int32_t q = 0; q < 8; q++ )
30763 {
30764 656 ri->d[q] = w->initD[q];
30765 656 }
30766 82 w->initialised = 1;
30767 82 }
30768 }
30769 2517 break;
30770
30771 case ScriptType::Generic:
30772 {
30773 444085 user_genscript& scr = user_scripts[script];
30774 444085 stack = &scr.stack;
30775 444085 ri = &scr.ri;
30776 444085 ri->genericdataref = script;
30777 444085 curscript = genericscripts[script];
30778 444085 scr.waitevent = false;
30779
2/2
✓ Branch 0 taken 443736 times.
✓ Branch 1 taken 349 times.
444085 if(!scr.initialized)
30780 {
30781 349 got_initialized = true;
30782 349 scr.initialized = true;
30783 349 memcpy(ri->d, scr.initd, 8 * sizeof(int32_t));
30784 349 }
30785 }
30786 444085 break;
30787
30788 case ScriptType::GenericFrozen:
30789 {
30790 1542 ri = genericActiveData.back();
30791 1542 ri->genericdataref = script;
30792 1542 curscript = genericscripts[script];
30793 1542 stack = generic_active_stack.back();
30794
2/2
✓ Branch 0 taken 1532 times.
✓ Branch 1 taken 10 times.
1542 if(!gen_active_initialized)
30795 {
30796 10 got_initialized = true;
30797 10 gen_active_initialized = true;
30798 10 memcpy(ri->d, user_scripts[script].initd, 8 * sizeof(int32_t));
30799 10 }
30800 }
30801 1542 break;
30802
30803 default:
30804 {
30805 al_trace("No other scripts are currently supported\n");
30806 return RUNSCRIPT_ERROR;
30807 }
30808 }
30809
30810 // Because qst.cpp likes to write script_data without setting this.
30811 9655213 curscript->meta.script_type = type;
30812
30813 // No need to do anything if the script is not valid.
30814 // An example of this is found in `playground.qst` player scripts, which have scripts with
30815 // a single 0xFFFF command.
30816 // Can't actually do this because we must unset `doscript` via the `scommand == 0xFFFF` handling in run_script_int.
30817 // Otherwise can get freeze, like in ending.cpp
30818 // if (!curscript->valid())
30819 // return RUNSCRIPT_OK;
30820
30821 9655213 script_funcrun = false;
30822
30823
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9655213 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9655213 if (DEBUG_PRINT_ZASM && !seen_scripts.contains(curscript->debug_id))
30824 {
30825 seen_scripts.insert(curscript->debug_id);
30826 ScriptDebugHandle h(ScriptDebugHandle::OutputSplit::ByScript, curscript);
30827 h.print_zasm(curScriptNum, curScriptIndex);
30828 }
30829
30830 9655213 JittedScriptHandle* jitted_script = nullptr;
30831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9655213 times.
9655213 if (jit_is_enabled())
30832 {
30833 9655213 auto it = jitted_scripts.find({curscript, ri});
30834
2/2
✓ Branch 0 taken 12105 times.
✓ Branch 1 taken 9643108 times.
9655213 if (it == jitted_scripts.end())
30835 {
30836 12105 jitted_scripts[{curscript, ri}] = jitted_script = jit_create_script_handle(curscript, ri);
30837 12105 }
30838 else
30839 {
30840 9643108 jitted_script = it->second;
30841 }
30842 9655213 }
30843
30844 9655213 runtime_script_debug_handle = nullptr;
30845
1/2
✓ Branch 0 taken 9655213 times.
✗ Branch 1 not taken.
9655213 if (script_debug_is_runtime_debugging())
30846 {
30847 if (!script_debug_handles.contains(curscript->debug_id))
30848 {
30849 script_debug_handles.emplace(curscript->debug_id, ScriptDebugHandle(ScriptDebugHandle::OutputSplit::ByFrame, curscript));
30850 }
30851 runtime_script_debug_handle = &script_debug_handles.at(curscript->debug_id);
30852 runtime_script_debug_handle->update_file();
30853 runtime_script_debug_handle->print(fmt::format("\n=== running script id: {} name: {} type: {} i: {} script: {}\n", curscript->debug_id, curscript->meta.script_name, ScriptTypeToString(type), i, script).c_str());
30854 }
30855
1/2
✓ Branch 0 taken 9655213 times.
✗ Branch 1 not taken.
9655213 if (script_debug_is_runtime_debugging() == 1)
30856 {
30857 runtime_script_debug_handle->print(script_debug_registers_and_stack_to_string().c_str());
30858 runtime_script_debug_handle->print("\n");
30859 }
30860
30861 int32_t result;
30862
2/2
✓ Branch 0 taken 9654221 times.
✓ Branch 1 taken 992 times.
9655213 if (jitted_script)
30863 {
30864
2/2
✓ Branch 0 taken 9574144 times.
✓ Branch 1 taken 80077 times.
9654221 if (got_initialized)
30865 80077 jit_reinit(jitted_script);
30866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9654221 times.
9654221 if (ri->waitframes)
30867 {
30868 --ri->waitframes;
30869 result = RUNSCRIPT_OK;
30870 }
30871 else
30872 {
30873 9654221 result = jit_run_script(jitted_script);
30874 }
30875 9654221 }
30876 else
30877 {
30878 992 result = run_script_int(false);
30879 }
30880
30881
6/16
✗ Branch 0 not taken.
✓ Branch 1 taken 9655213 times.
✓ Branch 2 taken 9655213 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9655213 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 9655213 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 9655213 times.
✓ Branch 10 taken 9655213 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
19310426 if (replay_is_active() && replay_get_meta_bool("debug_script_state"))
30882 {
30883 std::string str = script_debug_registers_and_stack_to_string();
30884 util::replstr(str, "\n", " ");
30885 replay_step_comment(str);
30886 }
30887
30888 #ifdef _SCRIPT_COUNTER
30889 if (replay_get_frame() > 10000-50)
30890 {
30891 al_trace("\nPrinting ZASM timings:\n\n");
30892
30893 std::vector<std::pair<int, int>> timing_results;
30894 for (int j = 0; j < NUMCOMMANDS; j++)
30895 {
30896 if (script_execount[j])
30897 {
30898 int32_t ms = script_timer[j] / 1000000.0;
30899 timing_results.push_back({j, ms});
30900 }
30901 }
30902 std::sort(timing_results.begin(), timing_results.end(), [](auto &left, auto &right) {
30903 return left.second > right.second;
30904 });
30905 for (auto &it : timing_results)
30906 {
30907 al_trace("Command %s took %d ms complete in %ld executions.\n",
30908 script_debug_command_to_string(it.first).c_str(), it.second, script_execount[it.first]);
30909 }
30910 }
30911 #endif
30912
30913
1/2
✓ Branch 0 taken 9655213 times.
✗ Branch 1 not taken.
9655213 if (runtime_script_debug_handle)
30914 runtime_script_debug_handle->print(fmt::format("result: {}\n", result).c_str());
30915 9655213 return result;
30916 10293791 }
30917
30918 712125966 int32_t run_script_int(bool is_jitted)
30919 {
30920 712125966 ScriptType type = curScriptType;
30921 712125966 word script = curScriptNum;
30922 712125966 int32_t i = curScriptIndex;
30923
30924 712125966 int commands_run = 0;
30925
2/2
✓ Branch 0 taken 712124974 times.
✓ Branch 1 taken 992 times.
712125966 if (is_jitted) goto j_command;
30926
30927
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 992 times.
992 if(ri->waitframes)
30928 {
30929 --ri->waitframes;
30930 return RUNSCRIPT_OK;
30931 }
30932 992 zs_vargs.clear();
30933
30934 #ifdef _FFDISSASSEMBLY
30935
30936 if(curscript->zasm[ri->pc].command != 0xFFFF)
30937 {
30938 #ifdef _FFONESCRIPTDISSASSEMBLY
30939 zc_trace_clear();
30940 #endif
30941
30942 switch(type)
30943 {
30944 case ScriptType::FFC:
30945 al_trace("\nStart of FFC script %i processing on FFC %i:\n", script, i);
30946 break;
30947
30948 case ScriptType::Item:
30949 al_trace("\nStart of item script %i processing:\n", script);
30950 break;
30951
30952 case ScriptType::Global:
30953 al_trace("\nStart of global script %I processing:\n", script);
30954 break;
30955 }
30956 }
30957
30958 #endif
30959
30960
2/4
✓ Branch 0 taken 992 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 992 times.
1984 if( FFCore.zasm_break_mode == ZASM_BREAK_ADVANCE_SCRIPT || FFCore.zasm_break_mode == ZASM_BREAK_SKIP_SCRIPT )
30961 {
30962 if( zasm_debugger )
30963 {
30964 //Halt on new script if set to advance to next script
30965 FFCore.zasm_break_mode = ZASM_BREAK_HALT;
30966 FFCore.TraceScriptIDs(true);
30967 coloured_console.safeprint((CConsoleLoggerEx::COLOR_RED |
30968 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK),"Breaking for script start\n");
30969 }
30970 else FFCore.zasm_break_mode = ZASM_BREAK_NONE;
30971 }
30972
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 992 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
992 else if( zasm_debugger && !(SKIPZASMPRINT()))
30973 {
30974 //Print new script metadata when starting script
30975 FFCore.TraceScriptIDs(true);
30976 coloured_console.safeprint((CConsoleLoggerEx::COLOR_RED |
30977 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK),"Start of script\n");
30978 }
30979
30980 j_command:
30981 712125966 bool is_debugging = script_debug_is_runtime_debugging() == 2;
30982 712125966 bool increment = true;
30983 712125966 word scommand = curscript->zasm[ri->pc].command;
30984 712125966 bool hit_invalid_zasm = false;
30985 712125966 bool no_dealloc = false;
30986
2/2
✓ Branch 0 taken 1005 times.
✓ Branch 1 taken 715214133 times.
715215138 while(scommand != 0xFFFF)
30987 {
30988 #ifdef _SCRIPT_COUNTER
30989 std::chrono::steady_clock::time_point start_time, end_time;
30990 start_time = std::chrono::steady_clock::now();
30991 #endif
30992
30993 715214133 scommand = curscript->zasm[ri->pc].command;
30994 715214133 sarg1 = curscript->zasm[ri->pc].arg1;
30995 715214133 sarg2 = curscript->zasm[ri->pc].arg2;
30996 715214133 sargstr = curscript->zasm[ri->pc].strptr;
30997 715214133 sargvec = curscript->zasm[ri->pc].vecptr;
30998 //zprint2("Executing zasm: %d,%d,%d,%d,%d\n",scommand,sarg1,sarg2,get_register(sarg1),get_register(sarg2));
30999
31000
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 715214133 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
715214133 if (is_debugging && (!is_jitted || commands_run > 0))
31001 {
31002 runtime_script_debug_handle->pre_command();
31003 }
31004
31005 715214133 bool waiting = true;
31006
4/6
✓ Branch 0 taken 705629394 times.
✓ Branch 1 taken 1862822 times.
✓ Branch 2 taken 177522 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7544395 times.
✗ Branch 5 not taken.
715214133 switch(scommand) //Handle waitframe-type commands first
31007 {
31008 case WAITDRAW:
31009 {
31010
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1862822 times.
1862822 if(script_funcrun)
31011 scommand = NOP;
31012
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1862822 times.
1862822 else switch(type)
31013 {
31014 case ScriptType::Generic:
31015 case ScriptType::GenericFrozen: //ignore waitdraws
31016 Z_scripterrlog("'Waitdraw()' is invalid in generic scripts, will be ignored\n");
31017 scommand = NOP;
31018 break;
31019 }
31020 1862822 break;
31021 }
31022 case WAITTO:
31023 {
31024
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 177522 times.
177522 if(script_funcrun)
31025 scommand = NOP;
31026
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 177522 times.
177522 else switch(type)
31027 {
31028 case ScriptType::GenericFrozen:
31029 //ignore, no warn/error
31030 scommand = NOP;
31031 break;
31032 case ScriptType::Generic:
31033 {
31034 177522 user_genscript& scr = user_scripts[script];
31035 177522 int32_t target = get_register(sarg1)/10000L;
31036 177522 bool atleast = get_register(sarg2)!=0;
31037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 177522 times.
177522 if(unsigned(target) > SCR_TIMING_END_FRAME)
31038 {
31039 Z_scripterrlog("Invalid value '%d' provided to 'WaitTo()'\n", target);
31040 scommand = NOP;
31041 break;
31042 }
31043
1/4
✓ Branch 0 taken 177522 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
177522 if(genscript_timing == target ||
31044
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 177522 times.
177522 (atleast && genscript_timing < target))
31045 {
31046 //Already that time, skip the command
31047 scommand = NOP;
31048 break;
31049 }
31050 177522 scr.waituntil = scr_timing(target);
31051 177522 scr.wait_atleast = atleast;
31052 177522 break;
31053 }
31054 default:
31055 Z_scripterrlog("'WaitTo()' is only valid in 'generic' scripts!\n");
31056 scommand = NOP;
31057 break;
31058 }
31059 177522 break;
31060 }
31061 case WAITEVENT:
31062 {
31063 if(script_funcrun)
31064 scommand = NOP;
31065 else switch(type)
31066 {
31067 case ScriptType::GenericFrozen:
31068 scommand = WAITFRAME;
31069 ri->d[0] = GENSCR_EVENT_NIL*10000; //no event
31070 break;
31071 case ScriptType::Generic:
31072 {
31073 user_genscript& scr = user_scripts[script];
31074 scr.waitevent = true;
31075 break;
31076 }
31077 default:
31078 Z_scripterrlog("'WaitEvent()' is only valid in 'generic' scripts!\n");
31079 scommand = NOP;
31080 break;
31081 }
31082 break;
31083 }
31084 case WAITFRAME:
31085 {
31086
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7544395 times.
7544395 if(script_funcrun)
31087 scommand = NOP;
31088
2/2
✓ Branch 0 taken 7277832 times.
✓ Branch 1 taken 266563 times.
7544395 else switch(type)
31089 {
31090 case ScriptType::Generic:
31091 266563 user_scripts[script].waituntil = SCR_TIMING_START_FRAME;
31092 266563 user_scripts[script].wait_atleast = false;
31093 266563 break;
31094 }
31095 7544395 break;
31096 }
31097 case WAITFRAMESR:
31098 {
31099 auto count = get_register(sarg1);
31100 if(script_funcrun || count <= 0)
31101 {
31102 scommand = NOP;
31103 break;
31104 }
31105 auto frames = count/10000;
31106 if(count%10000) ++frames; //round up decimals
31107 ri->waitframes = frames-1; //this frame doesn't count
31108 switch(type)
31109 {
31110 case ScriptType::Generic:
31111 user_scripts[script].waituntil = SCR_TIMING_START_FRAME;
31112 user_scripts[script].wait_atleast = false;
31113 break;
31114 }
31115 break;
31116 }
31117 705629394 default: waiting = false;
31118 705629394 }
31119
3/4
✓ Branch 0 taken 9584739 times.
✓ Branch 1 taken 705629394 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9584739 times.
715214133 if(waiting && scommand != NOP)
31120 9584739 break;
31121
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 705629394 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
705629394 if(waiting && is_jitted)
31122 break;
31123
31124 705629394 numInstructions++;
31125
2/2
✓ Branch 0 taken 704923792 times.
✓ Branch 1 taken 705602 times.
705629394 if(numInstructions==hangcount) // No need to check frequently
31126 {
31127 705602 numInstructions=0;
31128 705602 poll_keyboard();
31129 705602 checkQuitKeys();
31130
1/2
✓ Branch 0 taken 705602 times.
✗ Branch 1 not taken.
705602 if(Quit)
31131 scommand=0xFFFF;
31132 705602 }
31133
31134 //Handle manual breaking
31135
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 705629394 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
705629394 if( zasm_debugger && zc_readrawkey(KEY_INSERT, true))
31136 FFCore.zasm_break_mode = ZASM_BREAK_HALT;
31137 //Break
31138
1/2
✓ Branch 0 taken 705629394 times.
✗ Branch 1 not taken.
705629394 while( FFCore.zasm_break_mode == ZASM_BREAK_HALT )
31139 {
31140 poll_keyboard();
31141 if(zasm_advance()) break;
31142 checkQuitKeys();
31143 if(Quit)
31144 {
31145 scommand=0xFFFF;
31146 break;
31147 }
31148 }
31149
31150
1/2
✓ Branch 0 taken 705629394 times.
✗ Branch 1 not taken.
705629394 if ( zasm_debugger ) FFCore.ZASMPrintCommand(scommand);
31151
138/907
✓ Branch 0 taken 5580 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 57032 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 576754 times.
✓ Branch 7 taken 37304357 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 69461 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 62470826 times.
✓ Branch 33 taken 31809476 times.
✓ Branch 34 taken 38045023 times.
✗ Branch 35 not taken.
✓ Branch 36 taken 22042560 times.
✓ Branch 37 taken 2928911 times.
✓ Branch 38 taken 236289 times.
✓ Branch 39 taken 302 times.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✗ Branch 49 not taken.
✗ Branch 50 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 53 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
✗ Branch 56 not taken.
✓ Branch 57 taken 58814 times.
✗ Branch 58 not taken.
✗ Branch 59 not taken.
✗ Branch 60 not taken.
✗ Branch 61 not taken.
✗ Branch 62 not taken.
✗ Branch 63 not taken.
✗ Branch 64 not taken.
✗ Branch 65 not taken.
✗ Branch 66 not taken.
✗ Branch 67 not taken.
✗ Branch 68 not taken.
✓ Branch 69 taken 297 times.
✗ Branch 70 not taken.
✓ Branch 71 taken 7004366 times.
✗ Branch 72 not taken.
✗ Branch 73 not taken.
✗ Branch 74 not taken.
✓ Branch 75 taken 6979847 times.
✗ Branch 76 not taken.
✗ Branch 77 not taken.
✓ Branch 78 taken 294114397 times.
✗ Branch 79 not taken.
✗ Branch 80 not taken.
✗ Branch 81 not taken.
✗ Branch 82 not taken.
✗ Branch 83 not taken.
✗ Branch 84 not taken.
✗ Branch 85 not taken.
✓ Branch 86 taken 227724 times.
✓ Branch 87 taken 80 times.
✗ Branch 88 not taken.
✗ Branch 89 not taken.
✗ Branch 90 not taken.
✗ Branch 91 not taken.
✗ Branch 92 not taken.
✗ Branch 93 not taken.
✗ Branch 94 not taken.
✗ Branch 95 not taken.
✗ Branch 96 not taken.
✗ Branch 97 not taken.
✓ Branch 98 taken 708 times.
✗ Branch 99 not taken.
✗ Branch 100 not taken.
✓ Branch 101 taken 252 times.
✗ Branch 102 not taken.
✗ Branch 103 not taken.
✓ Branch 104 taken 6163735 times.
✗ Branch 105 not taken.
✓ Branch 106 taken 3204584 times.
✗ Branch 107 not taken.
✓ Branch 108 taken 76 times.
✓ Branch 109 taken 1263 times.
✓ Branch 110 taken 59701 times.
✗ Branch 111 not taken.
✓ Branch 112 taken 14918 times.
✗ Branch 113 not taken.
✓ Branch 114 taken 863764 times.
✗ Branch 115 not taken.
✓ Branch 116 taken 13724 times.
✓ Branch 117 taken 15144 times.
✗ Branch 118 not taken.
✗ Branch 119 not taken.
✓ Branch 120 taken 1 times.
✗ Branch 121 not taken.
✓ Branch 122 taken 93 times.
✗ Branch 123 not taken.
✗ Branch 124 not taken.
✗ Branch 125 not taken.
✗ Branch 126 not taken.
✗ Branch 127 not taken.
✗ Branch 128 not taken.
✗ Branch 129 not taken.
✗ Branch 130 not taken.
✗ Branch 131 not taken.
✗ Branch 132 not taken.
✓ Branch 133 taken 978 times.
✗ Branch 134 not taken.
✗ Branch 135 not taken.
✗ Branch 136 not taken.
✗ Branch 137 not taken.
✗ Branch 138 not taken.
✗ Branch 139 not taken.
✗ Branch 140 not taken.
✗ Branch 141 not taken.
✗ Branch 142 not taken.
✗ Branch 143 not taken.
✗ Branch 144 not taken.
✓ Branch 145 taken 1 times.
✗ Branch 146 not taken.
✗ Branch 147 not taken.
✗ Branch 148 not taken.
✓ Branch 149 taken 586 times.
✓ Branch 150 taken 1275 times.
✗ Branch 151 not taken.
✓ Branch 152 taken 68 times.
✗ Branch 153 not taken.
✓ Branch 154 taken 102 times.
✗ Branch 155 not taken.
✓ Branch 156 taken 31 times.
✗ Branch 157 not taken.
✗ Branch 158 not taken.
✗ Branch 159 not taken.
✗ Branch 160 not taken.
✗ Branch 161 not taken.
✗ Branch 162 not taken.
✗ Branch 163 not taken.
✗ Branch 164 not taken.
✗ Branch 165 not taken.
✗ Branch 166 not taken.
✗ Branch 167 not taken.
✓ Branch 168 taken 25969 times.
✓ Branch 169 taken 71 times.
✗ Branch 170 not taken.
✓ Branch 171 taken 25971 times.
✓ Branch 172 taken 31488 times.
✓ Branch 173 taken 2703958 times.
✗ Branch 174 not taken.
✗ Branch 175 not taken.
✗ Branch 176 not taken.
✗ Branch 177 not taken.
✗ Branch 178 not taken.
✗ Branch 179 not taken.
✗ Branch 180 not taken.
✗ Branch 181 not taken.
✓ Branch 182 taken 2539388 times.
✓ Branch 183 taken 77 times.
✗ Branch 184 not taken.
✗ Branch 185 not taken.
✗ Branch 186 not taken.
✗ Branch 187 not taken.
✗ Branch 188 not taken.
✗ Branch 189 not taken.
✗ Branch 190 not taken.
✓ Branch 191 taken 27 times.
✓ Branch 192 taken 20 times.
✗ Branch 193 not taken.
✗ Branch 194 not taken.
✓ Branch 195 taken 5580675 times.
✓ Branch 196 taken 153176 times.
✓ Branch 197 taken 191294 times.
✓ Branch 198 taken 3 times.
✗ Branch 199 not taken.
✗ Branch 200 not taken.
✗ Branch 201 not taken.
✗ Branch 202 not taken.
✗ Branch 203 not taken.
✗ Branch 204 not taken.
✓ Branch 205 taken 1427960 times.
✓ Branch 206 taken 62324724 times.
✓ Branch 207 taken 418989 times.
✓ Branch 208 taken 20185266 times.
✓ Branch 209 taken 332656 times.
✓ Branch 210 taken 34306 times.
✗ Branch 211 not taken.
✓ Branch 212 taken 17 times.
✗ Branch 213 not taken.
✗ Branch 214 not taken.
✗ Branch 215 not taken.
✗ Branch 216 not taken.
✓ Branch 217 taken 22 times.
✗ Branch 218 not taken.
✓ Branch 219 taken 34296 times.
✗ Branch 220 not taken.
✓ Branch 221 taken 3553 times.
✗ Branch 222 not taken.
✗ Branch 223 not taken.
✗ Branch 224 not taken.
✗ Branch 225 not taken.
✗ Branch 226 not taken.
✗ Branch 227 not taken.
✗ Branch 228 not taken.
✗ Branch 229 not taken.
✗ Branch 230 not taken.
✗ Branch 231 not taken.
✗ Branch 232 not taken.
✗ Branch 233 not taken.
✗ Branch 234 not taken.
✓ Branch 235 taken 2 times.
✓ Branch 236 taken 1 times.
✓ Branch 237 taken 384 times.
✓ Branch 238 taken 287 times.
✓ Branch 239 taken 6883 times.
✓ Branch 240 taken 3322 times.
✗ Branch 241 not taken.
✗ Branch 242 not taken.
✗ Branch 243 not taken.
✓ Branch 244 taken 79 times.
✗ Branch 245 not taken.
✓ Branch 246 taken 126 times.
✗ Branch 247 not taken.
✗ Branch 248 not taken.
✗ Branch 249 not taken.
✓ Branch 250 taken 5268 times.
✗ Branch 251 not taken.
✗ Branch 252 not taken.
✓ Branch 253 taken 170812 times.
✗ Branch 254 not taken.
✗ Branch 255 not taken.
✗ Branch 256 not taken.
✗ Branch 257 not taken.
✗ Branch 258 not taken.
✗ Branch 259 not taken.
✗ Branch 260 not taken.
✓ Branch 261 taken 63813 times.
✗ Branch 262 not taken.
✓ Branch 263 taken 79 times.
✓ Branch 264 taken 100 times.
✓ Branch 265 taken 5 times.
✓ Branch 266 taken 3750 times.
✗ Branch 267 not taken.
✗ Branch 268 not taken.
✗ Branch 269 not taken.
✗ Branch 270 not taken.
✗ Branch 271 not taken.
✗ Branch 272 not taken.
✗ Branch 273 not taken.
✗ Branch 274 not taken.
✗ Branch 275 not taken.
✗ Branch 276 not taken.
✗ Branch 277 not taken.
✗ Branch 278 not taken.
✗ Branch 279 not taken.
✗ Branch 280 not taken.
✓ Branch 281 taken 173 times.
✗ Branch 282 not taken.
✓ Branch 283 taken 2567 times.
✗ Branch 284 not taken.
✗ Branch 285 not taken.
✓ Branch 286 taken 10 times.
✗ Branch 287 not taken.
✓ Branch 288 taken 3666 times.
✗ Branch 289 not taken.
✗ Branch 290 not taken.
✗ Branch 291 not taken.
✗ Branch 292 not taken.
✗ Branch 293 not taken.
✗ Branch 294 not taken.
✗ Branch 295 not taken.
✓ Branch 296 taken 1201098 times.
✗ Branch 297 not taken.
✓ Branch 298 taken 2753647 times.
✗ Branch 299 not taken.
✓ Branch 300 taken 136832 times.
✗ Branch 301 not taken.
✓ Branch 302 taken 55814 times.
✗ Branch 303 not taken.
✗ Branch 304 not taken.
✗ Branch 305 not taken.
✗ Branch 306 not taken.
✗ Branch 307 not taken.
✗ Branch 308 not taken.
✓ Branch 309 taken 25412 times.
✗ Branch 310 not taken.
✗ Branch 311 not taken.
✗ Branch 312 not taken.
✓ Branch 313 taken 403497 times.
✓ Branch 314 taken 177544 times.
✗ Branch 315 not taken.
✗ Branch 316 not taken.
✗ Branch 317 not taken.
✗ Branch 318 not taken.
✗ Branch 319 not taken.
✗ Branch 320 not taken.
✓ Branch 321 taken 755007 times.
✗ Branch 322 not taken.
✗ Branch 323 not taken.
✗ Branch 324 not taken.
✗ Branch 325 not taken.
✗ Branch 326 not taken.
✗ Branch 327 not taken.
✗ Branch 328 not taken.
✗ Branch 329 not taken.
✗ Branch 330 not taken.
✗ Branch 331 not taken.
✗ Branch 332 not taken.
✗ Branch 333 not taken.
✗ Branch 334 not taken.
✗ Branch 335 not taken.
✗ Branch 336 not taken.
✗ Branch 337 not taken.
✗ Branch 338 not taken.
✗ Branch 339 not taken.
✗ Branch 340 not taken.
✗ Branch 341 not taken.
✗ Branch 342 not taken.
✗ Branch 343 not taken.
✗ Branch 344 not taken.
✗ Branch 345 not taken.
✗ Branch 346 not taken.
✗ Branch 347 not taken.
✗ Branch 348 not taken.
✗ Branch 349 not taken.
✗ Branch 350 not taken.
✗ Branch 351 not taken.
✗ Branch 352 not taken.
✗ Branch 353 not taken.
✓ Branch 354 taken 22 times.
✗ Branch 355 not taken.
✗ Branch 356 not taken.
✗ Branch 357 not taken.
✗ Branch 358 not taken.
✗ Branch 359 not taken.
✗ Branch 360 not taken.
✗ Branch 361 not taken.
✗ Branch 362 not taken.
✗ Branch 363 not taken.
✗ Branch 364 not taken.
✗ Branch 365 not taken.
✗ Branch 366 not taken.
✗ Branch 367 not taken.
✗ Branch 368 not taken.
✗ Branch 369 not taken.
✗ Branch 370 not taken.
✗ Branch 371 not taken.
✗ Branch 372 not taken.
✗ Branch 373 not taken.
✗ Branch 374 not taken.
✗ Branch 375 not taken.
✗ Branch 376 not taken.
✗ Branch 377 not taken.
✗ Branch 378 not taken.
✗ Branch 379 not taken.
✗ Branch 380 not taken.
✗ Branch 381 not taken.
✗ Branch 382 not taken.
✓ Branch 383 taken 12 times.
✓ Branch 384 taken 598 times.
✗ Branch 385 not taken.
✓ Branch 386 taken 15641785 times.
✗ Branch 387 not taken.
✓ Branch 388 taken 77262 times.
✗ Branch 389 not taken.
✓ Branch 390 taken 131917 times.
✗ Branch 391 not taken.
✓ Branch 392 taken 21343 times.
✗ Branch 393 not taken.
✓ Branch 394 taken 2363 times.
✗ Branch 395 not taken.
✓ Branch 396 taken 4 times.
✓ Branch 397 taken 27033 times.
✗ Branch 398 not taken.
✓ Branch 399 taken 42 times.
✓ Branch 400 taken 6259830 times.
✓ Branch 401 taken 593592 times.
✓ Branch 402 taken 122622 times.
✗ Branch 403 not taken.
✗ Branch 404 not taken.
✗ Branch 405 not taken.
✗ Branch 406 not taken.
✓ Branch 407 taken 15079 times.
✗ Branch 408 not taken.
✓ Branch 409 taken 132144 times.
✗ Branch 410 not taken.
✗ Branch 411 not taken.
✗ Branch 412 not taken.
✓ Branch 413 taken 16270801 times.
✗ Branch 414 not taken.
✗ Branch 415 not taken.
✗ Branch 416 not taken.
✓ Branch 417 taken 249 times.
✓ Branch 418 taken 5 times.
✓ Branch 419 taken 354940 times.
✗ Branch 420 not taken.
✗ Branch 421 not taken.
✓ Branch 422 taken 354943 times.
✓ Branch 423 taken 3 times.
✓ Branch 424 taken 3 times.
✓ Branch 425 taken 12696160 times.
✓ Branch 426 taken 16038753 times.
✓ Branch 427 taken 60 times.
✗ Branch 428 not taken.
✗ Branch 429 not taken.
✗ Branch 430 not taken.
✗ Branch 431 not taken.
✗ Branch 432 not taken.
✗ Branch 433 not taken.
✗ Branch 434 not taken.
✗ Branch 435 not taken.
✗ Branch 436 not taken.
✗ Branch 437 not taken.
✗ Branch 438 not taken.
✗ Branch 439 not taken.
✗ Branch 440 not taken.
✗ Branch 441 not taken.
✗ Branch 442 not taken.
✗ Branch 443 not taken.
✗ Branch 444 not taken.
✓ Branch 445 taken 2564 times.
✗ Branch 446 not taken.
✗ Branch 447 not taken.
✗ Branch 448 not taken.
✗ Branch 449 not taken.
✓ Branch 450 taken 26528 times.
✗ Branch 451 not taken.
✓ Branch 452 taken 146 times.
✗ Branch 453 not taken.
✗ Branch 454 not taken.
✗ Branch 455 not taken.
✗ Branch 456 not taken.
✗ Branch 457 not taken.
✗ Branch 458 not taken.
✗ Branch 459 not taken.
✗ Branch 460 not taken.
✗ Branch 461 not taken.
✗ Branch 462 not taken.
✗ Branch 463 not taken.
✓ Branch 464 taken 16962076 times.
✗ Branch 465 not taken.
✗ Branch 466 not taken.
✗ Branch 467 not taken.
✗ Branch 468 not taken.
✗ Branch 469 not taken.
✗ Branch 470 not taken.
✗ Branch 471 not taken.
✗ Branch 472 not taken.
✗ Branch 473 not taken.
✗ Branch 474 not taken.
✗ Branch 475 not taken.
✗ Branch 476 not taken.
✗ Branch 477 not taken.
✗ Branch 478 not taken.
✗ Branch 479 not taken.
✗ Branch 480 not taken.
✗ Branch 481 not taken.
✗ Branch 482 not taken.
✗ Branch 483 not taken.
✗ Branch 484 not taken.
✓ Branch 485 taken 3535588 times.
✓ Branch 486 taken 1 times.
✗ Branch 487 not taken.
✗ Branch 488 not taken.
✗ Branch 489 not taken.
✗ Branch 490 not taken.
✗ Branch 491 not taken.
✓ Branch 492 taken 11 times.
✗ Branch 493 not taken.
✗ Branch 494 not taken.
✗ Branch 495 not taken.
✗ Branch 496 not taken.
✗ Branch 497 not taken.
✗ Branch 498 not taken.
✗ Branch 499 not taken.
✗ Branch 500 not taken.
✗ Branch 501 not taken.
✗ Branch 502 not taken.
✗ Branch 503 not taken.
✗ Branch 504 not taken.
✗ Branch 505 not taken.
✗ Branch 506 not taken.
✗ Branch 507 not taken.
✗ Branch 508 not taken.
✗ Branch 509 not taken.
✗ Branch 510 not taken.
✗ Branch 511 not taken.
✗ Branch 512 not taken.
✗ Branch 513 not taken.
✗ Branch 514 not taken.
✗ Branch 515 not taken.
✗ Branch 516 not taken.
✗ Branch 517 not taken.
✗ Branch 518 not taken.
✓ Branch 519 taken 16 times.
✗ Branch 520 not taken.
✗ Branch 521 not taken.
✗ Branch 522 not taken.
✗ Branch 523 not taken.
✗ Branch 524 not taken.
✗ Branch 525 not taken.
✗ Branch 526 not taken.
✗ Branch 527 not taken.
✗ Branch 528 not taken.
✗ Branch 529 not taken.
✗ Branch 530 not taken.
✗ Branch 531 not taken.
✗ Branch 532 not taken.
✗ Branch 533 not taken.
✗ Branch 534 not taken.
✗ Branch 535 not taken.
✗ Branch 536 not taken.
✗ Branch 537 not taken.
✗ Branch 538 not taken.
✗ Branch 539 not taken.
✗ Branch 540 not taken.
✗ Branch 541 not taken.
✗ Branch 542 not taken.
✗ Branch 543 not taken.
✗ Branch 544 not taken.
✗ Branch 545 not taken.
✓ Branch 546 taken 15 times.
✗ Branch 547 not taken.
✗ Branch 548 not taken.
✗ Branch 549 not taken.
✗ Branch 550 not taken.
✗ Branch 551 not taken.
✗ Branch 552 not taken.
✗ Branch 553 not taken.
✗ Branch 554 not taken.
✗ Branch 555 not taken.
✗ Branch 556 not taken.
✗ Branch 557 not taken.
✗ Branch 558 not taken.
✗ Branch 559 not taken.
✗ Branch 560 not taken.
✗ Branch 561 not taken.
✗ Branch 562 not taken.
✗ Branch 563 not taken.
✗ Branch 564 not taken.
✗ Branch 565 not taken.
✗ Branch 566 not taken.
✗ Branch 567 not taken.
✗ Branch 568 not taken.
✗ Branch 569 not taken.
✗ Branch 570 not taken.
✗ Branch 571 not taken.
✗ Branch 572 not taken.
✗ Branch 573 not taken.
✗ Branch 574 not taken.
✗ Branch 575 not taken.
✗ Branch 576 not taken.
✗ Branch 577 not taken.
✗ Branch 578 not taken.
✗ Branch 579 not taken.
✗ Branch 580 not taken.
✗ Branch 581 not taken.
✗ Branch 582 not taken.
✗ Branch 583 not taken.
✗ Branch 584 not taken.
✗ Branch 585 not taken.
✗ Branch 586 not taken.
✗ Branch 587 not taken.
✗ Branch 588 not taken.
✗ Branch 589 not taken.
✗ Branch 590 not taken.
✗ Branch 591 not taken.
✗ Branch 592 not taken.
✗ Branch 593 not taken.
✗ Branch 594 not taken.
✗ Branch 595 not taken.
✗ Branch 596 not taken.
✗ Branch 597 not taken.
✗ Branch 598 not taken.
✗ Branch 599 not taken.
✗ Branch 600 not taken.
✗ Branch 601 not taken.
✗ Branch 602 not taken.
✗ Branch 603 not taken.
✗ Branch 604 not taken.
✗ Branch 605 not taken.
✗ Branch 606 not taken.
✗ Branch 607 not taken.
✗ Branch 608 not taken.
✗ Branch 609 not taken.
✗ Branch 610 not taken.
✗ Branch 611 not taken.
✗ Branch 612 not taken.
✗ Branch 613 not taken.
✗ Branch 614 not taken.
✗ Branch 615 not taken.
✗ Branch 616 not taken.
✗ Branch 617 not taken.
✗ Branch 618 not taken.
✗ Branch 619 not taken.
✗ Branch 620 not taken.
✗ Branch 621 not taken.
✗ Branch 622 not taken.
✗ Branch 623 not taken.
✗ Branch 624 not taken.
✗ Branch 625 not taken.
✗ Branch 626 not taken.
✗ Branch 627 not taken.
✗ Branch 628 not taken.
✗ Branch 629 not taken.
✗ Branch 630 not taken.
✗ Branch 631 not taken.
✗ Branch 632 not taken.
✗ Branch 633 not taken.
✗ Branch 634 not taken.
✗ Branch 635 not taken.
✗ Branch 636 not taken.
✗ Branch 637 not taken.
✗ Branch 638 not taken.
✗ Branch 639 not taken.
✗ Branch 640 not taken.
✗ Branch 641 not taken.
✗ Branch 642 not taken.
✗ Branch 643 not taken.
✗ Branch 644 not taken.
✗ Branch 645 not taken.
✗ Branch 646 not taken.
✗ Branch 647 not taken.
✗ Branch 648 not taken.
✗ Branch 649 not taken.
✗ Branch 650 not taken.
✗ Branch 651 not taken.
✗ Branch 652 not taken.
✗ Branch 653 not taken.
✗ Branch 654 not taken.
✗ Branch 655 not taken.
✗ Branch 656 not taken.
✗ Branch 657 not taken.
✗ Branch 658 not taken.
✗ Branch 659 not taken.
✗ Branch 660 not taken.
✗ Branch 661 not taken.
✗ Branch 662 not taken.
✗ Branch 663 not taken.
✗ Branch 664 not taken.
✗ Branch 665 not taken.
✗ Branch 666 not taken.
✗ Branch 667 not taken.
✗ Branch 668 not taken.
✗ Branch 669 not taken.
✗ Branch 670 not taken.
✗ Branch 671 not taken.
✗ Branch 672 not taken.
✗ Branch 673 not taken.
✗ Branch 674 not taken.
✗ Branch 675 not taken.
✗ Branch 676 not taken.
✗ Branch 677 not taken.
✗ Branch 678 not taken.
✗ Branch 679 not taken.
✗ Branch 680 not taken.
✗ Branch 681 not taken.
✗ Branch 682 not taken.
✗ Branch 683 not taken.
✗ Branch 684 not taken.
✗ Branch 685 not taken.
✗ Branch 686 not taken.
✗ Branch 687 not taken.
✗ Branch 688 not taken.
✗ Branch 689 not taken.
✗ Branch 690 not taken.
✗ Branch 691 not taken.
✗ Branch 692 not taken.
✗ Branch 693 not taken.
✗ Branch 694 not taken.
✗ Branch 695 not taken.
✗ Branch 696 not taken.
✗ Branch 697 not taken.
✗ Branch 698 not taken.
✗ Branch 699 not taken.
✗ Branch 700 not taken.
✗ Branch 701 not taken.
✗ Branch 702 not taken.
✗ Branch 703 not taken.
✗ Branch 704 not taken.
✗ Branch 705 not taken.
✗ Branch 706 not taken.
✗ Branch 707 not taken.
✗ Branch 708 not taken.
✗ Branch 709 not taken.
✗ Branch 710 not taken.
✗ Branch 711 not taken.
✗ Branch 712 not taken.
✗ Branch 713 not taken.
✗ Branch 714 not taken.
✗ Branch 715 not taken.
✗ Branch 716 not taken.
✗ Branch 717 not taken.
✗ Branch 718 not taken.
✗ Branch 719 not taken.
✗ Branch 720 not taken.
✗ Branch 721 not taken.
✗ Branch 722 not taken.
✗ Branch 723 not taken.
✗ Branch 724 not taken.
✗ Branch 725 not taken.
✗ Branch 726 not taken.
✗ Branch 727 not taken.
✗ Branch 728 not taken.
✗ Branch 729 not taken.
✗ Branch 730 not taken.
✗ Branch 731 not taken.
✗ Branch 732 not taken.
✗ Branch 733 not taken.
✗ Branch 734 not taken.
✗ Branch 735 not taken.
✗ Branch 736 not taken.
✗ Branch 737 not taken.
✗ Branch 738 not taken.
✗ Branch 739 not taken.
✗ Branch 740 not taken.
✗ Branch 741 not taken.
✗ Branch 742 not taken.
✗ Branch 743 not taken.
✗ Branch 744 not taken.
✗ Branch 745 not taken.
✗ Branch 746 not taken.
✗ Branch 747 not taken.
✗ Branch 748 not taken.
✗ Branch 749 not taken.
✗ Branch 750 not taken.
✗ Branch 751 not taken.
✗ Branch 752 not taken.
✗ Branch 753 not taken.
✗ Branch 754 not taken.
✗ Branch 755 not taken.
✗ Branch 756 not taken.
✗ Branch 757 not taken.
✗ Branch 758 not taken.
✗ Branch 759 not taken.
✗ Branch 760 not taken.
✗ Branch 761 not taken.
✗ Branch 762 not taken.
✗ Branch 763 not taken.
✗ Branch 764 not taken.
✗ Branch 765 not taken.
✗ Branch 766 not taken.
✗ Branch 767 not taken.
✗ Branch 768 not taken.
✗ Branch 769 not taken.
✗ Branch 770 not taken.
✗ Branch 771 not taken.
✗ Branch 772 not taken.
✗ Branch 773 not taken.
✗ Branch 774 not taken.
✗ Branch 775 not taken.
✗ Branch 776 not taken.
✗ Branch 777 not taken.
✗ Branch 778 not taken.
✗ Branch 779 not taken.
✗ Branch 780 not taken.
✗ Branch 781 not taken.
✗ Branch 782 not taken.
✗ Branch 783 not taken.
✗ Branch 784 not taken.
✗ Branch 785 not taken.
✗ Branch 786 not taken.
✗ Branch 787 not taken.
✗ Branch 788 not taken.
✗ Branch 789 not taken.
✗ Branch 790 not taken.
✗ Branch 791 not taken.
✗ Branch 792 not taken.
✗ Branch 793 not taken.
✗ Branch 794 not taken.
✗ Branch 795 not taken.
✗ Branch 796 not taken.
✗ Branch 797 not taken.
✗ Branch 798 not taken.
✗ Branch 799 not taken.
✗ Branch 800 not taken.
✗ Branch 801 not taken.
✗ Branch 802 not taken.
✗ Branch 803 not taken.
✗ Branch 804 not taken.
✗ Branch 805 not taken.
✗ Branch 806 not taken.
✗ Branch 807 not taken.
✗ Branch 808 not taken.
✗ Branch 809 not taken.
✓ Branch 810 taken 8 times.
✗ Branch 811 not taken.
✗ Branch 812 not taken.
✗ Branch 813 not taken.
✗ Branch 814 not taken.
✗ Branch 815 not taken.
✗ Branch 816 not taken.
✗ Branch 817 not taken.
✗ Branch 818 not taken.
✗ Branch 819 not taken.
✗ Branch 820 not taken.
✗ Branch 821 not taken.
✗ Branch 822 not taken.
✗ Branch 823 not taken.
✗ Branch 824 not taken.
✗ Branch 825 not taken.
✗ Branch 826 not taken.
✗ Branch 827 not taken.
✗ Branch 828 not taken.
✗ Branch 829 not taken.
✗ Branch 830 not taken.
✗ Branch 831 not taken.
✗ Branch 832 not taken.
✗ Branch 833 not taken.
✗ Branch 834 not taken.
✗ Branch 835 not taken.
✗ Branch 836 not taken.
✗ Branch 837 not taken.
✗ Branch 838 not taken.
✗ Branch 839 not taken.
✗ Branch 840 not taken.
✗ Branch 841 not taken.
✗ Branch 842 not taken.
✗ Branch 843 not taken.
✗ Branch 844 not taken.
✗ Branch 845 not taken.
✗ Branch 846 not taken.
✗ Branch 847 not taken.
✗ Branch 848 not taken.
✗ Branch 849 not taken.
✗ Branch 850 not taken.
✗ Branch 851 not taken.
✗ Branch 852 not taken.
✗ Branch 853 not taken.
✓ Branch 854 taken 1 times.
✓ Branch 855 taken 1 times.
✗ Branch 856 not taken.
✗ Branch 857 not taken.
✗ Branch 858 not taken.
✓ Branch 859 taken 1 times.
✗ Branch 860 not taken.
✗ Branch 861 not taken.
✗ Branch 862 not taken.
✗ Branch 863 not taken.
✓ Branch 864 taken 1 times.
✓ Branch 865 taken 1 times.
✗ Branch 866 not taken.
✗ Branch 867 not taken.
✓ Branch 868 taken 279 times.
✗ Branch 869 not taken.
✗ Branch 870 not taken.
✗ Branch 871 not taken.
✗ Branch 872 not taken.
✗ Branch 873 not taken.
✗ Branch 874 not taken.
✗ Branch 875 not taken.
✗ Branch 876 not taken.
✗ Branch 877 not taken.
✗ Branch 878 not taken.
✗ Branch 879 not taken.
✗ Branch 880 not taken.
✗ Branch 881 not taken.
✗ Branch 882 not taken.
✗ Branch 883 not taken.
✗ Branch 884 not taken.
✗ Branch 885 not taken.
✗ Branch 886 not taken.
✗ Branch 887 not taken.
✗ Branch 888 not taken.
✗ Branch 889 not taken.
✗ Branch 890 not taken.
✗ Branch 891 not taken.
✗ Branch 892 not taken.
✗ Branch 893 not taken.
✗ Branch 894 not taken.
✗ Branch 895 not taken.
✓ Branch 896 taken 1338 times.
✓ Branch 897 taken 301905 times.
✗ Branch 898 not taken.
✗ Branch 899 not taken.
✗ Branch 900 not taken.
✓ Branch 901 taken 73 times.
✗ Branch 902 not taken.
✓ Branch 903 taken 6 times.
✓ Branch 904 taken 8 times.
✓ Branch 905 taken 68 times.
✓ Branch 906 taken 10 times.
705629394 switch(scommand)
31152 {
31153 //always first
31154 case 0xFFFF: //invalid command
31155 {
31156 const char* type_str = ScriptTypeToString(type);
31157 switch(type)
31158 {
31159 case ScriptType::FFC:
31160 zprint("%s Script %s has exited.\n", type_str, ffcmap[i].scriptname.c_str()); break;
31161 case ScriptType::NPC:
31162 zprint("%s Script %s has exited.\n", type_str, npcmap[i].scriptname.c_str()); break;
31163 case ScriptType::Lwpn:
31164 zprint("%s Script %s has exited.\n", type_str, lwpnmap[i].scriptname.c_str()); break;
31165 case ScriptType::Ewpn:
31166 zprint("%s Script %s has exited.\n", type_str, ewpnmap[i].scriptname.c_str()); break;
31167 case ScriptType::ItemSprite:
31168 zprint("%s Script %s has exited.\n", type_str, itemspritemap[i].scriptname.c_str()); break;
31169 case ScriptType::Item:
31170 zprint("%s Script %s has exited.\n", type_str, itemmap[i].scriptname.c_str()); break;
31171 case ScriptType::Global:
31172 zprint("%s Script %s has exited.\n", type_str, globalmap[i].scriptname.c_str()); break;
31173 case ScriptType::Player:
31174 zprint("%s Script %s has exited.\n", type_str, playermap[i].scriptname.c_str()); break;
31175 case ScriptType::Screen:
31176 zprint("%s Script %s has exited.\n", type_str, screenmap[i].scriptname.c_str()); break;
31177 case ScriptType::OnMap:
31178 case ScriptType::DMap:
31179 case ScriptType::ActiveSubscreen:
31180 case ScriptType::PassiveSubscreen:
31181 zprint("%s Script %s has exited.\n", type_str, dmapmap[i].scriptname.c_str()); break;
31182 case ScriptType::Combo: zprint("%s Script %s has exited.\n", type_str, comboscriptmap[i].scriptname.c_str()); break;
31183
31184 default: break;
31185 }
31186 break;
31187 }
31188 case QUIT:
31189 69461 scommand = 0xFFFF;
31190 69461 break;
31191 case QUIT_NO_DEALLOC:
31192 scommand = 0xFFFF;
31193 no_dealloc = true;
31194 break;
31195
31196 case NOP: //No Operation. Do nothing. -Em
31197 break;
31198 case GOTO:
31199 {
31200 uint8_t invalid = 0;
31201 if(sarg1 < 0 )
31202 {
31203 const char* type_str = ScriptTypeToString(type);
31204 switch(type)
31205 {
31206 case ScriptType::FFC:
31207 Z_scripterrlog("%s Script %s attempted to GOTO an invalid jump to (%d).\n", type_str, ffcmap[i].scriptname.c_str(), sarg1); break;
31208 case ScriptType::NPC:
31209 Z_scripterrlog("%s Script %s attempted to GOTO an invalid jump to (%d).\n", type_str, npcmap[i].scriptname.c_str(), sarg1); break;
31210 case ScriptType::Lwpn:
31211 Z_scripterrlog("%s Script %s attempted to GOTO an invalid jump to (%d).\n", type_str, lwpnmap[i].scriptname.c_str(), sarg1); break;
31212 case ScriptType::Ewpn:
31213 Z_scripterrlog("%s Script %s attempted to GOTO an invalid jump to (%d).\n", type_str, ewpnmap[i].scriptname.c_str(), sarg1); break;
31214 case ScriptType::ItemSprite:
31215 Z_scripterrlog("%s Script %s attempted to GOTO an invalid jump to (%d).\n", type_str, itemspritemap[i].scriptname.c_str(), sarg1); break;
31216 case ScriptType::Item:
31217 Z_scripterrlog("%s Script %s attempted to GOTO an invalid jump to (%d).\n", type_str, itemmap[i].scriptname.c_str(), sarg1); break;
31218 case ScriptType::Global:
31219 Z_scripterrlog("%s Script %s attempted to GOTO an invalid jump to (%d).\n", type_str, globalmap[i].scriptname.c_str(), sarg1); break;
31220 case ScriptType::Player:
31221 Z_scripterrlog("%s Script %s attempted to GOTO an invalid jump to (%d).\n", type_str, playermap[i].scriptname.c_str(), sarg1); break;
31222 case ScriptType::Screen:
31223 Z_scripterrlog("%s Script %s attempted to GOTO an invalid jump to (%d).\n", type_str, screenmap[i].scriptname.c_str(), sarg1); break;
31224 case ScriptType::OnMap:
31225 case ScriptType::DMap:
31226 case ScriptType::ActiveSubscreen:
31227 case ScriptType::PassiveSubscreen:
31228 Z_scripterrlog("%s Script %s attempted to GOTO an invalid jump to (%d).\n", type_str, dmapmap[i].scriptname.c_str(), sarg1); break;
31229 case ScriptType::Combo: Z_scripterrlog("%s Script %s attempted to GOTO an invalid jump to (%d).\n", type_str, comboscriptmap[i].scriptname.c_str(), sarg1); break;
31230
31231 default: break;
31232 }
31233 invalid = 1; scommand = 0xFFFF;
31234 }
31235 if ( invalid ) break;
31236 ri->pc = sarg1;
31237 increment = false;
31238 break;
31239 }
31240 case GOTOR:
31241 {
31242 uint8_t invalid = 0;
31243 if(sarg1 < 0 )
31244 {
31245 const char* type_str = ScriptTypeToString(type);
31246 switch(type)
31247 {
31248 case ScriptType::FFC:
31249 Z_scripterrlog("%s Script %s attempted to GOTOR an invalid jump to (%d).\n", type_str, ffcmap[i].scriptname.c_str() ,sarg1); break;
31250 case ScriptType::NPC:
31251 Z_scripterrlog("%s Script %s attempted to GOTOR an invalid jump to (%d).\n", type_str, npcmap[i].scriptname.c_str(), sarg1); break;
31252 case ScriptType::Lwpn:
31253 Z_scripterrlog("%s Script %s attempted to GOTOR an invalid jump to (%d).\n", type_str, lwpnmap[i].scriptname.c_str(), sarg1); break;
31254 case ScriptType::Ewpn:
31255 Z_scripterrlog("%s Script %s attempted to GOTOR an invalid jump to (%d).\n", type_str, ewpnmap[i].scriptname.c_str(), sarg1); break;
31256 case ScriptType::ItemSprite:
31257 Z_scripterrlog("%s Script %s attempted to GOTOR an invalid jump to (%d).\n", type_str, itemspritemap[i].scriptname.c_str(), sarg1); break;
31258 case ScriptType::Item:
31259 Z_scripterrlog("%s Script %s attempted to GOTOR an invalid jump to (%d).\n", type_str, itemmap[i].scriptname.c_str(), sarg1); break;
31260 case ScriptType::Global:
31261 Z_scripterrlog("%s Script %s attempted to GOTOR an invalid jump to (%d).\n", type_str, globalmap[i].scriptname.c_str(), sarg1); break;
31262 case ScriptType::Player:
31263 Z_scripterrlog("%s Script %s attempted to GOTOR an invalid jump to (%d).\n", type_str, playermap[i].scriptname.c_str(), sarg1); break;
31264 case ScriptType::Screen:
31265 Z_scripterrlog("%s Script %s attempted to GOTOR an invalid jump to (%d).\n", type_str, screenmap[i].scriptname.c_str(), sarg1); break;
31266 case ScriptType::OnMap:
31267 case ScriptType::DMap:
31268 case ScriptType::ActiveSubscreen:
31269 case ScriptType::PassiveSubscreen:
31270 Z_scripterrlog("%s Script %s attempted to GOTOR an invalid jump to (%d).\n", type_str, dmapmap[i].scriptname.c_str(), sarg1); break;
31271 case ScriptType::Combo: Z_scripterrlog("%s Script %s attempted to GOTOR an invalid jump to (%d).\n", type_str, comboscriptmap[i].scriptname.c_str(), sarg1); break;
31272
31273 default: break;
31274 }
31275 invalid = 1; scommand = 0xFFFF;
31276 }
31277 if ( invalid ) break;
31278 ri->pc = (get_register(sarg1) / 10000) - 1;
31279 increment = false;
31280 }
31281 break;
31282
31283 case GOTOTRUE:
31284 if(ri->scriptflag & TRUEFLAG)
31285 {
31286 uint8_t invalid = 0;
31287 if(sarg1 < 0 )
31288 {
31289 const char* type_str = ScriptTypeToString(type);
31290 switch(type)
31291 {
31292 case ScriptType::FFC:
31293 Z_scripterrlog("%s Script %s attempted to GOTOTRUE an invalid jump to (%d).\n", type_str, ffcmap[i].scriptname.c_str(), sarg1); break;
31294 case ScriptType::NPC:
31295 Z_scripterrlog("%s Script %s attempted to GOTOTRUE an invalid jump to (%d).\n", type_str, npcmap[i].scriptname.c_str(), sarg1); break;
31296 case ScriptType::Lwpn:
31297 Z_scripterrlog("%s Script %s attempted to GOTOTRUE an invalid jump to (%d).\n", type_str, lwpnmap[i].scriptname.c_str(), sarg1); break;
31298 case ScriptType::Ewpn:
31299 Z_scripterrlog("%s Script %s attempted to GOTOTRUE an invalid jump to (%d).\n", type_str, ewpnmap[i].scriptname.c_str(), sarg1); break;
31300 case ScriptType::ItemSprite:
31301 Z_scripterrlog("%s Script %s attempted to GOTOTRUE an invalid jump to (%d).\n", type_str, itemspritemap[i].scriptname.c_str(), sarg1); break;
31302 case ScriptType::Item:
31303 Z_scripterrlog("%s Script %s attempted to GOTOTRUE an invalid jump to (%d).\n", type_str, itemmap[i].scriptname.c_str(), sarg1); break;
31304 case ScriptType::Global:
31305 Z_scripterrlog("%s Script %s attempted to GOTOTRUE an invalid jump to (%d).\n", type_str, globalmap[i].scriptname.c_str(), sarg1); break;
31306 case ScriptType::Player:
31307 Z_scripterrlog("%s Script %s attempted to GOTOTRUE an invalid jump to (%d).\n", type_str, playermap[i].scriptname.c_str(), sarg1); break;
31308 case ScriptType::Screen:
31309 Z_scripterrlog("%s Script %s attempted to GOTOTRUE an invalid jump to (%d).\n", type_str, screenmap[i].scriptname.c_str(), sarg1); break;
31310 case ScriptType::OnMap:
31311 case ScriptType::DMap:
31312 case ScriptType::ActiveSubscreen:
31313 case ScriptType::PassiveSubscreen:
31314 Z_scripterrlog("%s Script %s attempted to GOTOTRUE an invalid jump to (%d).\n", type_str, dmapmap[i].scriptname.c_str(), sarg1); break;
31315 case ScriptType::Combo: Z_scripterrlog("%s Script %s attempted to GOTOTRUE an invalid jump to (%d).\n", type_str, comboscriptmap[i].scriptname.c_str(), sarg1); break;
31316
31317 default: break;
31318 }
31319 invalid = 1; scommand = 0xFFFF;
31320 }
31321 if ( invalid ) break;
31322 ri->pc = sarg1;
31323 increment = false;
31324 }
31325
31326 break;
31327
31328 case GOTOFALSE:
31329 if(!(ri->scriptflag & TRUEFLAG))
31330 {
31331 uint8_t invalid = 0;
31332 if(sarg1 < 0 )
31333 {
31334 const char* type_str = ScriptTypeToString(type);
31335 switch(type)
31336 {
31337 case ScriptType::FFC:
31338 Z_scripterrlog("%s Script %s attempted to GOTOFALSE an invalid jump to (%d).\n", type_str, ffcmap[i].scriptname.c_str(), sarg1); break;
31339 case ScriptType::NPC:
31340 Z_scripterrlog("%s Script %s attempted to GOTOFALSE an invalid jump to (%d).\n", type_str, npcmap[i].scriptname.c_str(), sarg1); break;
31341 case ScriptType::Lwpn:
31342 Z_scripterrlog("%s Script %s attempted to GOTOFALSE an invalid jump to (%d).\n", type_str, lwpnmap[i].scriptname.c_str(), sarg1); break;
31343 case ScriptType::Ewpn:
31344 Z_scripterrlog("%s Script %s attempted to GOTOFALSE an invalid jump to (%d).\n", type_str, ewpnmap[i].scriptname.c_str(), sarg1); break;
31345 case ScriptType::ItemSprite:
31346 Z_scripterrlog("%s Script %s attempted to GOTOFALSE an invalid jump to (%d).\n", type_str, itemspritemap[i].scriptname.c_str(), sarg1); break;
31347 case ScriptType::Item:
31348 Z_scripterrlog("%s Script %s attempted to GOTOFALSE an invalid jump to (%d).\n", type_str, itemmap[i].scriptname.c_str(), sarg1); break;
31349 case ScriptType::Global:
31350 Z_scripterrlog("%s Script %s attempted to GOTOFALSE an invalid jump to (%d).\n", type_str, globalmap[i].scriptname.c_str(), sarg1); break;
31351 case ScriptType::Player:
31352 Z_scripterrlog("%s Script %s attempted to GOTOFALSE an invalid jump to (%d).\n", type_str, playermap[i].scriptname.c_str(), sarg1); break;
31353 case ScriptType::Screen:
31354 Z_scripterrlog("%s Script %s attempted to GOTOFALSE an invalid jump to (%d).\n", type_str, screenmap[i].scriptname.c_str(), sarg1); break;
31355 case ScriptType::OnMap:
31356 case ScriptType::DMap:
31357 case ScriptType::ActiveSubscreen:
31358 case ScriptType::PassiveSubscreen:
31359 Z_scripterrlog("%s Script %s attempted to GOTOFALSE an invalid jump to (%d).\n", type_str, dmapmap[i].scriptname.c_str(), sarg1); break;
31360 case ScriptType::Combo: Z_scripterrlog("%s Script %s attempted to GOTOFALSE an invalid jump to (%d).\n", type_str, comboscriptmap[i].scriptname.c_str(), sarg1); break;
31361
31362 default: break;
31363 }
31364 invalid = 1; scommand = 0xFFFF;
31365 }
31366 if ( invalid ) break;
31367 ri->pc = sarg1;
31368 increment = false;
31369 }
31370
31371 break;
31372
31373 case GOTOMORE:
31374 if(ri->scriptflag & MOREFLAG)
31375 {
31376 uint8_t invalid = 0;
31377 if(sarg1 < 0 )
31378 {
31379 const char* type_str = ScriptTypeToString(type);
31380 switch(type)
31381 {
31382 case ScriptType::FFC:
31383 Z_scripterrlog("%s Script %s attempted to GOTOMORE an invalid jump to (%d).\n", type_str, ffcmap[i].scriptname.c_str(), sarg1); break;
31384 case ScriptType::NPC:
31385 Z_scripterrlog("%s Script %s attempted to GOTOMORE an invalid jump to (%d).\n", type_str, npcmap[i].scriptname.c_str(), sarg1); break;
31386 case ScriptType::Lwpn:
31387 Z_scripterrlog("%s Script %s attempted to GOTOMORE an invalid jump to (%d).\n", type_str, lwpnmap[i].scriptname.c_str(), sarg1); break;
31388 case ScriptType::Ewpn:
31389 Z_scripterrlog("%s Script %s attempted to GOTOMORE an invalid jump to (%d).\n", type_str, ewpnmap[i].scriptname.c_str(), sarg1); break;
31390 case ScriptType::ItemSprite:
31391 Z_scripterrlog("%s Script %s attempted to GOTOMORE an invalid jump to (%d).\n", type_str, itemspritemap[i].scriptname.c_str(), sarg1); break;
31392 case ScriptType::Item:
31393 Z_scripterrlog("%s Script %s attempted to GOTOMORE an invalid jump to (%d).\n", type_str, itemmap[i].scriptname.c_str(), sarg1); break;
31394 case ScriptType::Global:
31395 Z_scripterrlog("%s Script %s attempted to GOTOMORE an invalid jump to (%d).\n", type_str, globalmap[i].scriptname.c_str(), sarg1); break;
31396 case ScriptType::Player:
31397 Z_scripterrlog("%s Script %s attempted to GOTOMORE an invalid jump to (%d).\n", type_str, playermap[i].scriptname.c_str(), sarg1); break;
31398 case ScriptType::Screen:
31399 Z_scripterrlog("%s Script %s attempted to GOTOMORE an invalid jump to (%d).\n", type_str, screenmap[i].scriptname.c_str(), sarg1); break;
31400 case ScriptType::OnMap:
31401 case ScriptType::DMap:
31402 case ScriptType::ActiveSubscreen:
31403 case ScriptType::PassiveSubscreen:
31404 Z_scripterrlog("%s Script %s attempted to GOTOMORE an invalid jump to (%d).\n", type_str, dmapmap[i].scriptname.c_str(), sarg1); break;
31405 case ScriptType::Combo: Z_scripterrlog("%s Script %s attempted to GOTOMORE an invalid jump to (%d).\n", type_str, comboscriptmap[i].scriptname.c_str(), sarg1); break;
31406
31407 default: break;
31408 }
31409 invalid = 1; scommand = 0xFFFF;
31410 }
31411 if ( invalid ) break;
31412 ri->pc = sarg1;
31413 increment = false;
31414 }
31415
31416 break;
31417
31418 case GOTOLESS:
31419 if(!(ri->scriptflag & MOREFLAG) || (!get_qr(qr_GOTOLESSNOTEQUAL) && (ri->scriptflag & TRUEFLAG)))
31420 {
31421 uint8_t invalid = 0;
31422 if(sarg1 < 0 )
31423 {
31424 const char* type_str = ScriptTypeToString(type);
31425 switch(type)
31426 {
31427 case ScriptType::FFC:
31428 Z_scripterrlog("%s Script %s attempted to GOTOLESS an invalid jump to (%d).\n", type_str, ffcmap[i].scriptname.c_str(), sarg1); break;
31429 case ScriptType::NPC:
31430 Z_scripterrlog("%s Script %s attempted to GOTOLESS an invalid jump to (%d).\n", type_str, npcmap[i].scriptname.c_str(), sarg1); break;
31431 case ScriptType::Lwpn:
31432 Z_scripterrlog("%s Script %s attempted to GOTOLESS an invalid jump to (%d).\n", type_str, lwpnmap[i].scriptname.c_str(), sarg1); break;
31433 case ScriptType::Ewpn:
31434 Z_scripterrlog("%s Script %s attempted to GOTOLESS an invalid jump to (%d).\n", type_str, ewpnmap[i].scriptname.c_str(), sarg1); break;
31435 case ScriptType::ItemSprite:
31436 Z_scripterrlog("%s Script %s attempted to GOTOLESS an invalid jump to (%d).\n", type_str, itemspritemap[i].scriptname.c_str(), sarg1); break;
31437 case ScriptType::Item:
31438 Z_scripterrlog("%s Script %s attempted to GOTOLESS an invalid jump to (%d).\n", type_str, itemmap[i].scriptname.c_str(), sarg1); break;
31439 case ScriptType::Global:
31440 Z_scripterrlog("%s Script %s attempted to GOTOLESS an invalid jump to (%d).\n", type_str, globalmap[i].scriptname.c_str(), sarg1); break;
31441 case ScriptType::Player:
31442 Z_scripterrlog("%s Script %s attempted to GOTOLESS an invalid jump to (%d).\n", type_str, playermap[i].scriptname.c_str(), sarg1); break;
31443 case ScriptType::Screen:
31444 Z_scripterrlog("%s Script %s attempted to GOTOLESS an invalid jump to (%d).\n", type_str, screenmap[i].scriptname.c_str(), sarg1); break;
31445 case ScriptType::OnMap:
31446 case ScriptType::DMap:
31447 case ScriptType::ActiveSubscreen:
31448 case ScriptType::PassiveSubscreen:
31449 Z_scripterrlog("%s Script %s attempted to GOTOLESS an invalid jump to (%d).\n", type_str, dmapmap[i].scriptname.c_str(), sarg1); break;
31450 case ScriptType::Combo: Z_scripterrlog("%s Script %s attempted to GOTOLESS an invalid jump to (%d).\n", type_str, comboscriptmap[i].scriptname.c_str(), sarg1); break;
31451
31452 default: break;
31453 }
31454 invalid = 1; scommand = 0xFFFF;
31455 }
31456 if ( invalid ) break;
31457 ri->pc = sarg1;
31458 increment = false;
31459 }
31460
31461 break;
31462
31463 case LOOP:
31464 {
31465 if(get_register(sarg2) > 0)
31466 {
31467 ri->pc = sarg1;
31468 increment = false;
31469 }
31470 else
31471 {
31472 set_register(sarg1, sarg1 - 1);
31473 }
31474 }
31475 break;
31476
31477 case RETURN:
31478 {
31479 ri->pc = SH::read_stack(ri->sp) - 1;
31480 ++ri->sp;
31481 ri->sp &= MASK_SP;
31482 increment = false;
31483 break;
31484 }
31485
31486 case SETTRUE:
31487 set_register(sarg1, (ri->scriptflag & TRUEFLAG) ? 1 : 0);
31488 break;
31489
31490 case SETFALSE:
31491 set_register(sarg1, (ri->scriptflag & TRUEFLAG) ? 0 : 1);
31492 break;
31493
31494 case SETMORE:
31495 set_register(sarg1, (ri->scriptflag & MOREFLAG) ? 1 : 0);
31496 break;
31497
31498 case SETLESS:
31499 set_register(sarg1, (!(ri->scriptflag & MOREFLAG)
31500 || (ri->scriptflag & TRUEFLAG)) ? 1 : 0);
31501 break;
31502
31503 case SETTRUEI:
31504 set_register(sarg1, (ri->scriptflag & TRUEFLAG) ? 10000 : 0);
31505 break;
31506
31507 case SETFALSEI:
31508 set_register(sarg1, (ri->scriptflag & TRUEFLAG) ? 0 : 10000);
31509 break;
31510
31511 case SETMOREI:
31512 set_register(sarg1, (ri->scriptflag & MOREFLAG) ? 10000 : 0);
31513 break;
31514
31515 case SETLESSI:
31516 set_register(sarg1, (!(ri->scriptflag & MOREFLAG)
31517 || (ri->scriptflag & TRUEFLAG)) ? 10000 : 0);
31518 break;
31519
31520 case READPODARRAYR:
31521 {
31522 62470826 do_readpod(false);
31523 62470826 break;
31524 }
31525 case READPODARRAYV:
31526 {
31527 31809476 do_readpod(true);
31528 31809476 break;
31529 }
31530 case WRITEPODARRAYRR:
31531 {
31532 38045023 do_writepod(false,false);
31533 38045023 break;
31534 }
31535 case WRITEPODARRAYRV:
31536 {
31537 do_writepod(false,true);
31538 break;
31539 }
31540 case WRITEPODARRAYVR:
31541 {
31542 22042560 do_writepod(true,false);
31543 22042560 break;
31544 }
31545 case WRITEPODARRAYVV:
31546 {
31547 2928911 do_writepod(true,true);
31548 2928911 break;
31549 }
31550 case WRITEPODSTRING:
31551 {
31552 236289 do_writepodstr();
31553 236289 break;
31554 }
31555 case WRITEPODARRAY:
31556 {
31557 302 do_writepodarr();
31558 302 break;
31559 }
31560 case ZCLASS_CONSTRUCT:
31561 {
31562 do_constructclass(type,script,i);
31563 break;
31564 }
31565 case ZCLASS_READ:
31566 {
31567 do_readclass();
31568 break;
31569 }
31570 case ZCLASS_WRITE:
31571 {
31572 do_writeclass();
31573 break;
31574 }
31575 case ZCLASS_FREE:
31576 {
31577 do_freeclass();
31578 break;
31579 }
31580 case ZCLASS_OWN:
31581 {
31582 if(user_object* obj = checkObject(get_register(sarg1), true))
31583 {
31584 obj->own(type,i);
31585 }
31586 break;
31587 }
31588 case STARTDESTRUCTOR:
31589 {
31590 zprint2("STARTDESTRUCTOR: %s\n", sargstr->c_str());
31591 //This opcode's EXISTENCE indicates the first opcode
31592 //of a user_object destructor function.
31593 break;
31594 }
31595 case ZCLASS_GLOBALIZE:
31596 {
31597 if(user_object* obj = checkObject(get_register(sarg1), true))
31598 {
31599 obj->disown();
31600 }
31601 break;
31602 }
31603
31604 case NOT:
31605 do_not(false);
31606 break;
31607
31608 case COMPAREV:
31609 do_comp(true);
31610 break;
31611 case COMPAREV2:
31612 do_comp(true,true);
31613 break;
31614
31615 case COMPARER:
31616 do_comp(false);
31617 break;
31618
31619 case STRCMPR:
31620 do_internal_strcmp();
31621 break;
31622
31623 case STRICMPR:
31624 do_internal_stricmp();
31625 break;
31626
31627 case SETV:
31628 do_set(true, type, i);
31629 break;
31630
31631 case SETR:
31632 do_set(false, type, i);
31633 break;
31634
31635 case PUSHR:
31636 do_push(false);
31637 break;
31638
31639 case PUSHV:
31640 do_push(true);
31641 break;
31642
31643 case PEEK:
31644 58814 do_peek();
31645 58814 break;
31646 case POP:
31647 do_pop();
31648 break;
31649
31650 case POPARGS:
31651 do_pops();
31652 break;
31653
31654 case LOADI:
31655 do_loadi();
31656 break;
31657
31658 case STOREI:
31659 do_storei();
31660 break;
31661
31662 case LOADD:
31663 do_loadd();
31664 break;
31665
31666 case STORED:
31667 do_stored();
31668 break;
31669
31670 case LOAD1:
31671 do_loada(0);
31672 break;
31673
31674 case LOAD2:
31675 do_loada(1);
31676 break;
31677
31678 case SETA1:
31679 do_seta(0);
31680 break;
31681
31682 case SETA2:
31683 do_seta(1);
31684 break;
31685
31686 case ALLOCATEGMEMR:
31687 if(type == ScriptType::Global) do_allocatemem(false, false, type, i);
31688
31689 break;
31690
31691 case ALLOCATEGMEMV:
31692
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 297 times.
297 if(type == ScriptType::Global) do_allocatemem(true, false, type, i);
31693
31694 297 break;
31695
31696 case ALLOCATEMEMR:
31697 do_allocatemem(false, true, type, i);
31698 break;
31699
31700 case ALLOCATEMEMV:
31701 7004366 do_allocatemem(true, true, type, i);
31702 7004366 break;
31703
31704 case RESIZEARRAYR:
31705 do_resize_array();
31706 break;
31707 case OWNARRAYR:
31708 do_own_array(get_register(sarg1)/10000, type, i);
31709 break;
31710 case DESTROYARRAYR:
31711 do_destroy_array();
31712 break;
31713
31714 case DEALLOCATEMEMR:
31715 6979847 do_deallocatemem();
31716 6979847 break;
31717
31718 case SAVEGAMESTRUCTS:
31719 using_SRAM = 1;
31720 FFCore.do_savegamestructs(false,false);
31721 using_SRAM = 0;
31722 break;
31723 case READGAMESTRUCTS:
31724 using_SRAM = 1;
31725 FFCore.do_loadgamestructs(false,false);
31726 using_SRAM = 0;
31727 break;
31728 case ARRAYSIZE:
31729 294114397 do_arraysize();
31730 294114397 break;
31731 case ARRAYSIZEB:
31732 do_arraysize();
31733 break;
31734 case ARRAYSIZEF:
31735 do_arraysize();
31736 break;
31737 case ARRAYSIZEN:
31738 do_arraysize();
31739 break;
31740 case ARRAYSIZEI:
31741 do_arraysize();
31742 break;
31743 case ARRAYSIZEID:
31744 do_arraysize();
31745 break;
31746 case ARRAYSIZEL:
31747 do_arraysize();
31748 break;
31749 case ARRAYSIZEE:
31750 do_arraysize();
31751 break;
31752
31753 case GETFFCSCRIPT:
31754 227724 do_getffcscript();
31755 227724 break;
31756 case GETITEMSCRIPT:
31757 80 do_getitemscript();
31758 80 break;
31759
31760 case CASTBOOLI:
31761 do_boolcast(false);
31762 break;
31763
31764 case CASTBOOLF:
31765 do_boolcast(true);
31766 break;
31767
31768 case ADDV:
31769 do_add(true);
31770 break;
31771
31772 case ADDR:
31773 do_add(false);
31774 break;
31775
31776 case SUBV:
31777 do_sub(true);
31778 break;
31779 case SUBV2:
31780 do_sub(true,true);
31781 break;
31782
31783 case SUBR:
31784 do_sub(false);
31785 break;
31786
31787 case MULTV:
31788 do_mult(true);
31789 break;
31790
31791 case MULTR:
31792 do_mult(false);
31793 break;
31794
31795 case DIVV:
31796 do_div(true);
31797 break;
31798 case DIVV2:
31799 708 do_div(true,true);
31800 708 break;
31801
31802 case DIVR:
31803 do_div(false);
31804 break;
31805
31806 case MODV:
31807 do_mod(true);
31808 break;
31809 case MODV2:
31810 252 do_mod(true,true);
31811 252 break;
31812
31813 case MODR:
31814 do_mod(false);
31815 break;
31816
31817 case SINV:
31818 do_trig(true, 0);
31819 break;
31820
31821 case SINR:
31822 6163735 do_trig(false, 0);
31823 6163735 break;
31824
31825 case COSV:
31826 do_trig(true, 1);
31827 break;
31828
31829 case COSR:
31830 3204584 do_trig(false, 1);
31831 3204584 break;
31832
31833 case TANV:
31834 do_trig(true, 2);
31835 break;
31836
31837 case TANR:
31838 76 do_trig(false, 2);
31839 76 break;
31840
31841 case DEGTORAD:
31842 1263 do_degtorad();
31843 1263 break;
31844
31845 case RADTODEG:
31846 59701 do_radtodeg();
31847 59701 break;
31848
31849 case STRINGLENGTH:
31850 FFCore.do_strlen(false);
31851 break;
31852
31853 case ARCSINR:
31854 14918 do_asin(false);
31855 14918 break;
31856
31857 case ARCCOSR:
31858 do_acos(false);
31859 break;
31860
31861 case ARCTANR:
31862 863764 do_arctan();
31863 863764 break;
31864
31865 //Text ptr functions
31866 case FONTHEIGHTR:
31867 do_fontheight();
31868 break;
31869 case STRINGWIDTHR:
31870 13724 do_strwidth();
31871 13724 break;
31872 case CHARWIDTHR:
31873 15144 do_charwidth();
31874 15144 break;
31875 case MESSAGEWIDTHR:
31876 ri->d[rEXP1] = 10000* do_msgwidth(get_register(sarg1)/10000, "Text->MessageWidth()");
31877 break;
31878 case MESSAGEHEIGHTR:
31879 ri->d[rEXP1] = 10000* do_msgheight(get_register(sarg1)/10000, "Text->MessageHeight()");
31880 break;
31881 //
31882
31883 //String.h functions 2.55 Alpha 23
31884 1 case STRINGCOMPARE: FFCore.do_strcmp(); break;
31885 case STRINGICOMPARE: FFCore.do_stricmp(); break;
31886 93 case STRINGCOPY: FFCore.do_strcpy(false,false); break;
31887 case ARRAYCOPY: FFCore.do_arraycpy(false,false); break;
31888 case STRINGNCOMPARE: FFCore.do_strncmp(); break;
31889 case STRINGNICOMPARE: FFCore.do_strnicmp(); break;
31890
31891 //More string.h functions, 19th May, 2019
31892 case XLEN: FFCore.do_xlen(false); break;
31893 case XTOI: FFCore.do_xtoi(false); break;
31894 case ILEN: FFCore.do_ilen(false); break;
31895 case ATOI: FFCore.do_atoi(false); break;
31896 case STRCSPN: FFCore.do_strcspn(); break;
31897 case STRSTR: FFCore.do_strstr(); break;
31898 case XTOA: FFCore.do_xtoa(); break;
31899 978 case ITOA: FFCore.do_itoa(); break;
31900 case ITOACAT: FFCore.do_itoacat(); break;
31901 case STRCAT: FFCore.do_strcat(); break;
31902 case STRSPN: FFCore.do_strspn(); break;
31903 case STRCHR: FFCore.do_strchr(); break;
31904 case STRRCHR: FFCore.do_strrchr(); break;
31905 case XLEN2: FFCore.do_xlen2(); break;
31906 case XTOI2: FFCore.do_xtoi2(); break;
31907 case ILEN2: FFCore.do_ilen2(); break;
31908 case ATOI2: FFCore.do_atoi2(); break;
31909 case REMCHR2: FFCore.do_remchr2(); break;
31910 case UPPERTOLOWER: FFCore.do_UpperToLower(false); break;
31911 1 case LOWERTOUPPER: FFCore.do_LowerToUpper(false); break;
31912 case CONVERTCASE: FFCore.do_ConvertCase(false); break;
31913
31914 case GETNPCSCRIPT: FFCore.do_getnpcscript(); break;
31915 case GETCOMBOSCRIPT: FFCore.do_getcomboscript(); break;
31916 586 case GETLWEAPONSCRIPT: FFCore.do_getlweaponscript(); break;
31917 1275 case GETEWEAPONSCRIPT: FFCore.do_geteweaponscript(); break;
31918 case GETHEROSCRIPT: FFCore.do_getheroscript(); break;
31919 68 case GETGENERICSCRIPT: FFCore.do_getgenericscript(); break;
31920 case GETGLOBALSCRIPT: FFCore.do_getglobalscript(); break;
31921 102 case GETDMAPSCRIPT: FFCore.do_getdmapscript(); break;
31922 case GETSCREENSCRIPT: FFCore.do_getscreenscript(); break;
31923 31 case GETSPRITESCRIPT: FFCore.do_getitemspritescript(); break;
31924 case GETUNTYPEDSCRIPT: FFCore.do_getuntypedscript(); break;
31925 case GETSUBSCREENSCRIPT:FFCore.do_getsubscreenscript(); break;
31926 case GETNPCBYNAME: FFCore.do_getnpcbyname(); break;
31927 case GETITEMBYNAME: FFCore.do_getitembyname(); break;
31928 case GETCOMBOBYNAME: FFCore.do_getcombobyname(); break;
31929 case GETDMAPBYNAME: FFCore.do_getdmapbyname(); break;
31930
31931 case ABSR:
31932 do_abs(false);
31933 break;
31934
31935 case MINR:
31936 do_min(false);
31937 break;
31938
31939 case MINV:
31940 do_min(true);
31941 break;
31942
31943 case MAXR:
31944 do_max(false);
31945 break;
31946 case MAXV:
31947 do_max(true);
31948 break;
31949
31950 case MAXVARG:
31951 25969 FFCore.do_varg_max();
31952 25969 break;
31953 case MINVARG:
31954 71 FFCore.do_varg_min();
31955 71 break;
31956 case CHOOSEVARG:
31957 FFCore.do_varg_choose();
31958 break;
31959
31960 case PUSHVARGV:
31961 25971 do_push_varg(true);
31962 25971 break;
31963 case PUSHVARGR:
31964 31488 do_push_varg(false);
31965 31488 break;
31966
31967 case RNDR:
31968 2703958 do_rnd(false);
31969 2703958 break;
31970
31971 case RNDV:
31972 do_rnd(true);
31973 break;
31974
31975 case SRNDR:
31976 do_srnd(false);
31977 break;
31978
31979 case SRNDV:
31980 do_srnd(true);
31981 break;
31982
31983 case SRNDRND:
31984 do_srndrnd();
31985 break;
31986
31987 case GETRTCTIMER:
31988 FFCore.getRTC(false);
31989 break;
31990 case GETRTCTIMEV:
31991 FFCore.getRTC(true);
31992 break;
31993
31994 case FACTORIAL:
31995 do_factorial(false);
31996 break;
31997
31998 case SQROOTV:
31999 do_sqroot(true);
32000 break;
32001
32002 case SQROOTR:
32003 2539388 do_sqroot(false);
32004 2539388 break;
32005
32006 case POWERR:
32007 77 do_power(false);
32008 77 break;
32009 case POWERV:
32010 do_power(true);
32011 break;
32012 case POWERV2:
32013 do_power(true,true);
32014 break;
32015
32016 case LPOWERR:
32017 do_lpower(false);
32018 break;
32019 case LPOWERV:
32020 do_lpower(true);
32021 break;
32022 case LPOWERV2:
32023 do_lpower(true,true);
32024 break;
32025
32026 case IPOWERR:
32027 do_ipower(false);
32028 break;
32029
32030 case IPOWERV:
32031 do_ipower(true);
32032 break;
32033
32034 case LOG10:
32035 27 do_log10(false);
32036 27 break;
32037
32038 case LOGE:
32039 20 do_naturallog(false);
32040 20 break;
32041
32042 case ANDR:
32043 do_and(false);
32044 break;
32045
32046 case ANDV:
32047 do_and(true);
32048 break;
32049
32050 case ORR:
32051 5580675 do_or(false);
32052 5580675 break;
32053
32054 case ORV:
32055 153176 do_or(true);
32056 153176 break;
32057
32058 case XORR:
32059 191294 do_xor(false);
32060 191294 break;
32061
32062 case XORV:
32063 3 do_xor(true);
32064 3 break;
32065
32066 case NANDR:
32067 do_nand(false);
32068 break;
32069
32070 case NANDV:
32071 do_nand(true);
32072 break;
32073
32074 case NORR:
32075 do_nor(false);
32076 break;
32077
32078 case NORV:
32079 do_nor(true);
32080 break;
32081
32082 case XNORR:
32083 do_xnor(false);
32084 break;
32085
32086 case XNORV:
32087 do_xnor(true);
32088 break;
32089
32090 case BITNOT:
32091 1427960 do_bitwisenot(false);
32092 1427960 break;
32093
32094 case LSHIFTR:
32095 62324724 do_lshift(false);
32096 62324724 break;
32097
32098 case LSHIFTV:
32099 418989 do_lshift(true);
32100 418989 break;
32101
32102 case RSHIFTR:
32103 20185266 do_rshift(false);
32104 20185266 break;
32105
32106 case RSHIFTV:
32107 332656 do_rshift(true);
32108 332656 break;
32109
32110 case ANDR32:
32111 34306 do_and32(false);
32112 34306 break;
32113
32114 case ANDV32:
32115 do_and32(true);
32116 break;
32117
32118 case ORR32:
32119 17 do_or32(false);
32120 17 break;
32121
32122 case ORV32:
32123 do_or32(true);
32124 break;
32125
32126 case XORR32:
32127 do_xor32(false);
32128 break;
32129
32130 case XORV32:
32131 do_xor32(true);
32132 break;
32133
32134 case BITNOT32:
32135 do_bitwisenot32(false);
32136 break;
32137
32138 case LSHIFTR32:
32139 22 do_lshift32(false);
32140 22 break;
32141
32142 case LSHIFTV32:
32143 do_lshift32(true);
32144 break;
32145
32146 case RSHIFTR32:
32147 34296 do_rshift32(false);
32148 34296 break;
32149
32150 case RSHIFTV32:
32151 do_rshift32(true);
32152 break;
32153
32154 case TRACER:
32155 3553 FFCore.do_trace(false);
32156 3553 break;
32157
32158 case TRACELR:
32159 FFCore.do_tracel(false);
32160 break;
32161
32162 case TRACEV:
32163 FFCore.do_trace(true);
32164 break;
32165
32166 case TRACE2R:
32167 FFCore.do_tracebool(false);
32168 break;
32169
32170 //Zap and Wavy Effects
32171 case FXWAVYR:
32172 FFCore.do_fx_wavy(false);
32173 break;
32174 case FXZAPR:
32175 FFCore.do_fx_zap(false);
32176 break;
32177 //Zap and Wavy Effects
32178 case FXWAVYV:
32179 FFCore.do_fx_wavy(true);
32180 break;
32181 case FXZAPV:
32182 FFCore.do_fx_zap(true);
32183 break;
32184 case GREYSCALER:
32185 FFCore.do_greyscale(false);
32186 break;
32187 case GREYSCALEV:
32188 FFCore.do_greyscale(true);
32189 break;
32190 case MONOCHROMER:
32191 FFCore.do_monochromatic(false);
32192 break;
32193 case MONOCHROMEV:
32194 FFCore.do_monochromatic(true);
32195 break;
32196
32197 case TRACE2V:
32198 FFCore.do_tracebool(true);
32199 break;
32200
32201 case TRACE3:
32202 FFCore.do_tracenl();
32203 break;
32204
32205 case TRACE4:
32206 2 FFCore.do_cleartrace();
32207 2 break;
32208
32209 case TRACE5:
32210 1 FFCore.do_tracetobase();
32211 1 break;
32212
32213 case TRACE6:
32214 384 FFCore.do_tracestring();
32215 384 break;
32216
32217 case PRINTFV:
32218 287 FFCore.do_printf(true, false);
32219 287 break;
32220 case SPRINTFV:
32221 6883 FFCore.do_sprintf(true, false);
32222 6883 break;
32223
32224 case PRINTFVARG:
32225 3322 FFCore.do_printf(true, true);
32226 3322 break;
32227 case SPRINTFVARG:
32228 FFCore.do_sprintf(true, true);
32229 break;
32230
32231 case BREAKPOINT:
32232 if( zasm_debugger )
32233 {
32234 FFCore.do_breakpoint();
32235 }
32236 break;
32237
32238 case WARP:
32239 do_warp(true);
32240 break;
32241
32242 case WARPR:
32243 79 do_warp(false);
32244 79 break;
32245
32246 case PITWARP:
32247 do_pitwarp(true);
32248 break;
32249
32250 case PITWARPR:
32251 126 do_pitwarp(false);
32252 126 break;
32253
32254 case BREAKSHIELD:
32255 do_breakshield();
32256 break;
32257
32258 case SELECTAWPNV:
32259 do_selectweapon(true, 1);
32260 break;
32261
32262 case SELECTAWPNR:
32263 5580 do_selectweapon(false, 1);
32264 5580 break;
32265
32266 case SELECTBWPNV:
32267 do_selectweapon(true, 0);
32268 break;
32269
32270 case SELECTBWPNR:
32271 5268 do_selectweapon(false, 0);
32272 5268 break;
32273
32274 case SELECTXWPNR:
32275 do_selectweapon(false, 2);
32276 break;
32277
32278 case SELECTYWPNR:
32279 do_selectweapon(false, 3);
32280 break;
32281
32282 case PLAYSOUNDR:
32283 170812 do_sfx(false);
32284 170812 break;
32285
32286 case PLAYSOUNDV:
32287 do_sfx(true);
32288 break;
32289
32290 case ADJUSTSFXVOLUMER: FFCore.do_adjustsfxvolume(false); break;
32291 case ADJUSTSFXVOLUMEV: FFCore.do_adjustsfxvolume(true); break;
32292 case ADJUSTVOLUMER: FFCore.do_adjustvolume(false); break;
32293 case ADJUSTVOLUMEV: FFCore.do_adjustvolume(true); break;
32294
32295 case TRIGGERSECRETR:
32296 FFScript::do_triggersecret(false);
32297 break;
32298
32299 case TRIGGERSECRETV:
32300 FFScript::do_triggersecret(true);
32301 break;
32302
32303 case PLAYMIDIR:
32304 63813 do_midi(false);
32305 63813 break;
32306
32307 case PLAYMIDIV:
32308 do_midi(true);
32309 break;
32310
32311 case PLAYENHMUSIC:
32312 79 do_enh_music(false);
32313 79 break;
32314
32315 case GETMUSICFILE:
32316 100 do_get_enh_music_filename(false);
32317 100 break;
32318
32319 case GETMUSICTRACK:
32320 5 do_get_enh_music_track(false);
32321 5 break;
32322
32323 case SETDMAPENHMUSIC:
32324 3750 do_set_dmap_enh_music(false);
32325 3750 break;
32326
32327 // Audio->
32328
32329 case ENDSOUNDR:
32330 stop_sfx(false);
32331 break;
32332
32333 case ENDSOUNDV:
32334 stop_sfx(true);
32335 break;
32336
32337 case PAUSESOUNDR:
32338 pause_sfx(false);
32339 break;
32340
32341 case PAUSESOUNDV:
32342 pause_sfx(true);
32343 break;
32344
32345 case RESUMESOUNDR:
32346 resume_sfx(false);
32347 break;
32348
32349 case RESUMESOUNDV:
32350 resume_sfx(true);
32351 break;
32352
32353
32354
32355 case PAUSESFX:
32356 {
32357 int32_t sound = ri->d[rINDEX]/10000;
32358 pause_sfx(sound);
32359
32360 }
32361 break;
32362
32363 case RESUMESFX:
32364 {
32365 int32_t sound = ri->d[rINDEX]/10000;
32366 resume_sfx(sound);
32367 }
32368 break;
32369
32370 case ADJUSTSFX:
32371 {
32372 do_sfx_ex(false);
32373 }
32374 break;
32375
32376 case PLAYSOUNDEX:
32377 {
32378 do_sfx_ex(true);
32379 }
32380 break;
32381
32382 case GETSFXCOMPLETION:
32383 {
32384 do_get_sfx_completion();
32385 }
32386 break;
32387
32388 case CONTINUESFX:
32389 {
32390 int32_t sound = ri->d[rINDEX]/10000;
32391 //Backend::sfx->cont_sfx(sound);
32392
32393 //! cont_sfx was not ported to the new back end!!!
32394 // I believe this restarted the loop.
32395 resume_sfx(sound);
32396 //What was the old instruction, again? Did it exist? -Z
32397 //continue_sfx(sound);
32398 }
32399 break;
32400
32401
32402 /*
32403 case STOPITEMSOUND:
32404 void stop_item_sfx(int32_t family)
32405 */
32406
32407 // Note: these have never worked.
32408 case PAUSEMUSIC:
32409 //What was the instruction prior to adding backends?
32410 //! The pauseAll() function pauses sfx, not music, so this instruction is not doing what I intended. -Z
32411 //Check AllOff() -Z
32412 //zcmusic_pause(ZCMUSIC* zcm, int32_t pause); is in zcmusic.h
32413 // midi_paused = true;
32414 //pause_all_sfx();
32415
32416 //Backend::sfx->pauseAll();
32417 break;
32418 case RESUMEMUSIC:
32419 //What was the instruction prior to adding backends?
32420 //Check AllOff() -Z
32421 //resume_all_sfx();
32422 // midi_paused = false;
32423 //Backend::sfx->resumeAll();
32424 break;
32425
32426 //!!! typecasting
32427 case LWPNARRPTR:
32428 case EWPNARRPTR:
32429 case ITEMARRPTR:
32430 case IDATAARRPTR:
32431 case FFCARRPTR:
32432 case BOOLARRPTR:
32433 case NPCARRPTR:
32434
32435 case LWPNARRPTR2:
32436 case EWPNARRPTR2:
32437 case ITEMARRPTR2:
32438 case IDATAARRPTR2:
32439 case FFCARRPTR2:
32440 case BOOLARRPTR2:
32441 case NPCARRPTR2:
32442 FFScript::do_typedpointer_typecast(false);
32443 break;
32444
32445 case MSGSTRR:
32446 173 do_message(false);
32447 173 break;
32448
32449 case MSGSTRV:
32450 do_message(true);
32451 break;
32452
32453 case ITEMNAME:
32454 2567 do_getitemname();
32455 2567 break;
32456
32457 case NPCNAME:
32458 do_getnpcname();
32459 break;
32460
32461 case NPCDATAGETNAME:
32462 FFCore.do_getnpcdata_getname();
32463 break;
32464
32465 case GETSAVENAME:
32466 10 do_getsavename();
32467 10 break;
32468
32469 case SETSAVENAME:
32470 do_setsavename();
32471 break;
32472
32473 case GETMESSAGE:
32474 3666 do_getmessage(false);
32475 3666 break;
32476 case SETMESSAGE:
32477 do_setmessage(false);
32478 break;
32479
32480 case GETDMAPNAME:
32481 do_getdmapname(false);
32482 break;
32483
32484 case GETDMAPTITLE:
32485 do_getdmaptitle(false);
32486 break;
32487
32488 case GETDMAPINTRO:
32489 do_getdmapintro(false);
32490 break;
32491
32492 case SETDMAPNAME:
32493 do_setdmapname(false);
32494 break;
32495
32496 case SETDMAPTITLE:
32497 do_setdmaptitle(false);
32498 break;
32499
32500 case SETDMAPINTRO:
32501 do_setdmapintro(false);
32502 break;
32503
32504 case LOADLWEAPONR:
32505 1201098 do_loadlweapon(false);
32506 1201098 break;
32507
32508 case LOADLWEAPONV:
32509 do_loadlweapon(true);
32510 break;
32511
32512 case LOADEWEAPONR:
32513 2753647 do_loadeweapon(false);
32514 2753647 break;
32515
32516 case LOADEWEAPONV:
32517 do_loadeweapon(true);
32518 break;
32519
32520 case LOADITEMR:
32521 136832 do_loaditem(false);
32522 136832 break;
32523
32524 case LOADITEMV:
32525 do_loaditem(true);
32526 break;
32527
32528 case LOADITEMDATAR:
32529 55814 do_loaditemdata(false);
32530 55814 break;
32531
32532 //New Datatypes
32533 case LOADSHOPR:
32534 FFScript::do_loadshopdata(false);
32535 break;
32536 case LOADSHOPV:
32537 FFScript::do_loadshopdata(true);
32538 break;
32539
32540 case LOADINFOSHOPR:
32541 FFScript::do_loadinfoshopdata(false);
32542 break;
32543 case LOADINFOSHOPV:
32544 FFScript::do_loadinfoshopdata(true);
32545 break;
32546 case LOADNPCDATAR:
32547 FFScript::do_loadnpcdata(false);
32548 break;
32549 case LOADNPCDATAV:
32550 FFScript::do_loadnpcdata(true);
32551 break;
32552
32553 case LOADCOMBODATAR:
32554 25412 FFScript::do_loadcombodata(false);
32555 25412 break;
32556 case LOADCOMBODATAV:
32557 FFScript::do_loadcombodata(true);
32558 break;
32559
32560 case LOADMAPDATAR:
32561 FFScript::do_loadmapdata(false);
32562 break;
32563 case LOADMAPDATAV:
32564 FFScript::do_loadmapdata(true);
32565 break;
32566 case LOADTMPSCR:
32567 403497 FFScript::do_loadmapdata_tempscr(false);
32568 403497 break;
32569 case LOADSCROLLSCR:
32570 177544 FFScript::do_loadmapdata_scrollscr(false);
32571 177544 break;
32572
32573 case LOADSPRITEDATAR:
32574 FFScript::do_loadspritedata(false);
32575 break;
32576 case LOADSPRITEDATAV:
32577 FFScript::do_loadspritedata(true);
32578 break;
32579
32580 case LOADSCREENDATAR:
32581 FFScript::do_loadscreendata(false);
32582 break;
32583 case LOADSCREENDATAV:
32584 FFScript::do_loadscreendata(true);
32585 break;
32586
32587 case LOADBITMAPDATAR:
32588 FFScript::do_loadbitmapid(false);
32589 break;
32590
32591
32592 case LOADBITMAPDATAV:
32593 FFScript::do_loadbitmapid(true);
32594 break;
32595
32596 //functions
32597 case LOADDMAPDATAR: //command
32598 755007 FFScript::do_loaddmapdata(false); break;
32599 case LOADDMAPDATAV: //command
32600 FFScript::do_loaddmapdata(true); break;
32601 case LOADDIRECTORYR:
32602 FFCore.do_loaddirectory(); break;
32603 case LOADSTACK:
32604 FFCore.do_loadstack(); break;
32605 case CREATEPALDATA:
32606 FFCore.do_create_paldata(); break;
32607 case CREATEPALDATACLR:
32608 FFCore.do_create_paldata_clr(); break;
32609 case MIXCLR:
32610 FFCore.do_mix_clr(); break;
32611 case CREATERGBHEX:
32612 FFCore.do_create_rgb_hex(); break;
32613 case CREATERGB:
32614 FFCore.do_create_rgb(); break;
32615 case CONVERTFROMRGB:
32616 FFCore.do_convert_from_rgb(); break;
32617 case CONVERTTORGB:
32618 FFCore.do_convert_to_rgb(); break;
32619 case PALDATALOADLEVEL:
32620 FFCore.do_paldata_load_level(); break;
32621 case PALDATALOADSPRITE:
32622 FFCore.do_paldata_load_sprite(); break;
32623 case PALDATALOADMAIN:
32624 FFCore.do_paldata_load_main(); break;
32625 case PALDATALOADCYCLE:
32626 FFCore.do_paldata_load_cycle(); break;
32627 case PALDATALOADBITMAP:
32628 FFCore.do_paldata_load_bitmap(); break;
32629 case PALDATAWRITELEVEL:
32630 FFCore.do_paldata_write_level(); break;
32631 case PALDATAWRITELEVELCS:
32632 FFCore.do_paldata_write_levelcset(); break;
32633 case PALDATAWRITESPRITE:
32634 FFCore.do_paldata_write_sprite(); break;
32635 case PALDATAWRITESPRITECS:
32636 FFCore.do_paldata_write_spritecset(); break;
32637 case PALDATAWRITEMAIN:
32638 FFCore.do_paldata_write_main(); break;
32639 case PALDATAWRITEMAINCS:
32640 FFCore.do_paldata_write_maincset(); break;
32641 case PALDATAWRITECYCLE:
32642 FFCore.do_paldata_write_cycle(); break;
32643 case PALDATAWRITECYCLECS:
32644 FFCore.do_paldata_write_cyclecset(); break;
32645 case PALDATAVALIDCLR:
32646 FFCore.do_paldata_colorvalid(); break;
32647 case PALDATACLEARCLR:
32648 FFCore.do_paldata_clearcolor(); break;
32649 case PALDATACLEARCSET:
32650 FFCore.do_paldata_clearcset(); break;
32651 case PALDATAMIX:
32652 FFCore.do_paldata_mix(); break;
32653 case PALDATAMIXCS:
32654 FFCore.do_paldata_mixcset(); break;
32655 case PALDATACOPY:
32656 FFCore.do_paldata_copy(); break;
32657 case PALDATACOPYCSET:
32658 FFCore.do_paldata_copycset(); break;
32659 case PALDATAFREE:
32660 if (user_paldata* pd = checkPalData(ri->paldataref, "Free()", true))
32661 {
32662 pd->clear();
32663 }
32664 break;
32665 case PALDATAOWN:
32666 if (user_paldata* pd = checkPalData(ri->paldataref, "Own()", false))
32667 {
32668 pd->own(type, i);
32669 }
32670 break;
32671 case LOADDROPSETR: //command
32672 FFCore.do_loaddropset(false); break;
32673 case LOADRNG: //command
32674 22 FFCore.do_loadrng(); break;
32675 case LOADBOTTLETYPE: //command
32676 FFCore.do_loadbottle(false); break;
32677 case LOADBSHOPDATA: //command
32678 FFCore.do_loadbottleshop(false); break;
32679
32680 case ITEMGETDISPLAYNAME: //command
32681 item_display_name(false); break;
32682 case ITEMSETDISPLAYNAME: //command
32683 item_display_name(true); break;
32684 case ITEMGETSHOWNNAME: //command
32685 item_shown_name(); break;
32686
32687 case DMAPDATAGETNAMER: //command
32688 FFScript::do_getDMapData_dmapname(false); break;
32689 case DMAPDATAGETNAMEV: //command
32690 FFScript::do_getDMapData_dmapname(true); break;
32691
32692 case DMAPDATASETNAMER: //command
32693 FFScript::do_setDMapData_dmapname(false); break;
32694 case DMAPDATASETNAMEV: //command
32695 FFScript::do_setDMapData_dmapname(true); break;
32696
32697
32698
32699 case DMAPDATAGETTITLER: //command
32700 FFScript::do_getDMapData_dmaptitle(false); break;
32701 case DMAPDATAGETTITLEV: //command
32702 FFScript::do_getDMapData_dmaptitle(true); break;
32703 case DMAPDATASETTITLER: //command
32704 FFScript::do_setDMapData_dmaptitle(false); break;
32705 case DMAPDATASETTITLEV: //command
32706 FFScript::do_setDMapData_dmaptitle(true); break;
32707
32708
32709 case DMAPDATAGETINTROR: //command
32710 FFScript::do_getDMapData_dmapintro(false); break;
32711 case DMAPDATAGETINTROV: //command
32712 FFScript::do_getDMapData_dmapintro(true); break;
32713 case DMAPDATANSETITROR: //command
32714 FFScript::do_setDMapData_dmapintro(false); break;
32715 case DMAPDATASETINTROV: //command
32716 FFScript::do_setDMapData_dmapintro(true); break;
32717
32718
32719 case DMAPDATAGETMUSICR: //command, string to load a music file
32720 FFScript::do_getDMapData_music(false); break;
32721 case DMAPDATAGETMUSICV: //command, string to load a music file
32722 FFScript::do_getDMapData_music(true); break;
32723 case DMAPDATASETMUSICR: //command, string to load a music file
32724 FFScript::do_setDMapData_music(false); break;
32725 case DMAPDATASETMUSICV: //command, string to load a music file
32726 FFScript::do_setDMapData_music(true); break;
32727
32728 case LOADMESSAGEDATAR: //COMMAND
32729 FFScript::do_loadmessagedata(false);
32730 break;
32731 case LOADMESSAGEDATAV: //COMMAND
32732 FFScript::do_loadmessagedata(false);
32733 break;
32734
32735
32736 case MESSAGEDATASETSTRINGR: //command
32737 FFScript::do_messagedata_setstring(false);
32738 break;
32739 case MESSAGEDATASETSTRINGV: //command
32740 FFScript::do_messagedata_setstring(false);
32741 break;
32742
32743 case MESSAGEDATAGETSTRINGR: //command
32744 FFScript::do_messagedata_getstring(false);
32745 break;
32746 case MESSAGEDATAGETSTRINGV: //command
32747 FFScript::do_messagedata_getstring(false);
32748 break;
32749 case LOADITEMDATAV:
32750 do_loaditemdata(true);
32751 break;
32752
32753 case LOADNPCBYSUID:
32754 12 FFCore.do_loadnpc_by_script_uid(false);
32755 12 break;
32756
32757 case LOADLWEAPONBYSUID:
32758 598 FFCore.do_loadlweapon_by_script_uid(false);
32759 598 break;
32760
32761 case LOADWEAPONCBYSUID:
32762 FFCore.do_loadeweapon_by_script_uid(false);
32763 break;
32764
32765 case LOADNPCR:
32766 15641785 do_loadnpc(false);
32767 15641785 break;
32768
32769 case LOADNPCV:
32770 do_loadnpc(true);
32771 break;
32772
32773 case CREATELWEAPONR:
32774 77262 do_createlweapon(false);
32775 77262 break;
32776
32777 case CREATELWEAPONV:
32778 do_createlweapon(true);
32779 break;
32780
32781 case CREATEEWEAPONR:
32782 131917 do_createeweapon(false);
32783 131917 break;
32784
32785 case CREATEEWEAPONV:
32786 do_createeweapon(true);
32787 break;
32788
32789 case CREATEITEMR:
32790 21343 do_createitem(false);
32791 21343 break;
32792
32793 case CREATEITEMV:
32794 do_createitem(true);
32795 break;
32796
32797 case CREATENPCR:
32798 2363 do_createnpc(false);
32799 2363 break;
32800
32801 case CREATENPCV:
32802 do_createnpc(true);
32803 break;
32804
32805 case ISVALIDARRAY:
32806 4 do_isvalidarray();
32807 4 break;
32808
32809 case ISVALIDITEM:
32810 27033 do_isvaliditem();
32811 27033 break;
32812
32813 case ISVALIDBITMAP:
32814 FFCore.do_isvalidbitmap();
32815 break;
32816
32817 case ISALLOCATEDBITMAP:
32818 42 FFCore.do_isallocatedbitmap();
32819 42 break;
32820
32821 case ISVALIDNPC:
32822 6259830 do_isvalidnpc();
32823 6259830 break;
32824
32825 case ISVALIDLWPN:
32826 593592 do_isvalidlwpn();
32827 593592 break;
32828
32829 case ISVALIDEWPN:
32830 122622 do_isvalidewpn();
32831 122622 break;
32832
32833 case LWPNMAKEANGULAR:
32834 do_lwpnmakeangular();
32835 break;
32836
32837 case EWPNMAKEANGULAR:
32838 do_ewpnmakeangular();
32839 break;
32840
32841 case LWPNMAKEDIRECTIONAL:
32842 do_lwpnmakedirectional();
32843 break;
32844
32845 case EWPNMAKEDIRECTIONAL:
32846 do_ewpnmakedirectional();
32847 break;
32848
32849 case LWPNUSESPRITER:
32850 15079 do_lwpnusesprite(false);
32851 15079 break;
32852
32853 case LWPNUSESPRITEV:
32854 do_lwpnusesprite(true);
32855 break;
32856
32857 case EWPNUSESPRITER:
32858 132144 do_ewpnusesprite(false);
32859 132144 break;
32860
32861 case EWPNUSESPRITEV:
32862 do_ewpnusesprite(true);
32863 break;
32864
32865 case CLEARSPRITESR:
32866 do_clearsprites(false);
32867 break;
32868
32869 case CLEARSPRITESV:
32870 do_clearsprites(true);
32871 break;
32872
32873 case ISSOLID:
32874 16270801 do_issolid();
32875 16270801 break;
32876
32877 case MAPDATAISSOLID:
32878 do_mapdataissolid();
32879 break;
32880
32881 case MAPDATAISSOLIDLYR:
32882 do_mapdataissolid_layer();
32883 break;
32884
32885 case ISSOLIDLAYER:
32886 do_issolid_layer();
32887 break;
32888
32889 case SETSIDEWARP:
32890 249 do_setsidewarp();
32891 249 break;
32892
32893 case SETTILEWARP:
32894 5 do_settilewarp();
32895 5 break;
32896
32897 case GETSIDEWARPDMAP:
32898 354940 do_getsidewarpdmap(false);
32899 354940 break;
32900
32901 case GETSIDEWARPSCR:
32902 do_getsidewarpscr(false);
32903 break;
32904
32905 case GETSIDEWARPTYPE:
32906 do_getsidewarptype(false);
32907 break;
32908
32909 case GETTILEWARPDMAP:
32910 354943 do_gettilewarpdmap(false);
32911 354943 break;
32912
32913 case GETTILEWARPSCR:
32914 3 do_gettilewarpscr(false);
32915 3 break;
32916
32917 case GETTILEWARPTYPE:
32918 3 do_gettilewarptype(false);
32919 3 break;
32920
32921 case LAYERSCREEN:
32922 12696160 do_layerscreen();
32923 12696160 break;
32924
32925 case LAYERMAP:
32926 16038753 do_layermap();
32927 16038753 break;
32928
32929 case SECRETS:
32930 60 do_triggersecrets();
32931 60 break;
32932
32933 case GETSCREENFLAGS:
32934 do_getscreenflags();
32935 break;
32936
32937 case GETSCREENEFLAGS:
32938 do_getscreeneflags();
32939 break;
32940
32941 case GRAPHICSGETPIXEL:
32942 FFCore.do_graphics_getpixel();
32943 break;
32944 case GRAPHICSCOUNTCOLOR:
32945 FFCore.do_bmpcollision();
32946 break;
32947
32948 case GETSCREENDOOR:
32949 do_getscreendoor();
32950 break;
32951
32952 case GETSCREENENEMY:
32953 do_getscreennpc();
32954 break;
32955
32956 //screendata and mapdata
32957 case SETSCREENENEMY:
32958 { //void SetScreenEnemy(int32_t map, int32_t screen, int32_t index, int32_t value);
32959 int32_t map = (ri->d[rINDEX2] / 10000) - 1;
32960 int32_t scrn = ri->d[rEXP1] / 10000;
32961 int32_t index = ri->d[rINDEX] / 10000;
32962 int32_t nn = ri->d[rEXP2]/10000;
32963
32964 // int32_t x;
32965
32966 // zprint("ri->d[rEXP2] is (%i), trying to use for '%s'\n", nn, "nn");
32967 // zprint("ri->d[rEXP1] is (%i), trying to use for '%s'\n", scrn, "scrn");
32968 // zprint("ri->d[rINDEX2] is (%i), trying to use for '%s'\n", map, "map");
32969 // zprint("ri->d[rINDEX] is (%i), trying to use for '%s'\n", index, "index");
32970
32971 if(BC::checkMapID(map, "Game->SetScreenEnemy(...map...)") != SH::_NoError ||
32972 BC::checkBounds(scrn, 0, 0x87, "Game->SetScreenEnemy(...screen...)") != SH::_NoError ||
32973 BC::checkBounds(index, 0, 9, "Game->SetScreenEnemy(...index...)") != SH::_NoError)
32974 return RUNSCRIPT_ERROR;
32975
32976 // if ( BC::checkBounds(nn, 0, 2, "Game->SetScreenEnemy(...enemy...)") != SH::_NoError) x = 1;
32977 // if ( BC::checkBounds(map, 20, 21, "Game->SetScreenEnemy(...map...)") != SH::_NoError) x = 2;
32978 FFScript::set_screenenemy(&TheMaps[map * MAPSCRS + scrn], index, nn);
32979 }
32980 break;
32981
32982 case SETSCREENDOOR:
32983 { //void SetScreenDoor(int32_t map, int32_t screen, int32_t index, int32_t value);
32984 int32_t map = (ri->d[rINDEX2] / 10000) - 1;
32985 int32_t scrn = ri->d[rEXP1] / 10000;
32986 int32_t index = ri->d[rINDEX] / 10000;
32987 int32_t nn = ri->d[rEXP2]/10000;
32988
32989 if(BC::checkMapID(map, "Game->SetScreenDoor(...map...)") != SH::_NoError ||
32990 BC::checkBounds(scrn, 0, 0x87, "Game->SetScreenDoor(...screen...)") != SH::_NoError ||
32991 BC::checkBounds(index, 0, 3, "Game->SetScreenDoor(...doorindex...)") != SH::_NoError)
32992 {
32993 return RUNSCRIPT_ERROR; break;
32994 }
32995 else
32996 {
32997 FFScript::set_screendoor(&TheMaps[map * MAPSCRS + scrn], index, nn);
32998 break;
32999 }
33000
33001 }
33002
33003 case GETSCREENLAYOP:
33004 do_getscreenLayerOpacity();
33005 break;
33006 case GETSCREENSECCMB:
33007 do_getscreenSecretCombo();
33008 break;
33009 case GETSCREENSECCST:
33010 do_getscreenSecretCSet();
33011 break;
33012 case GETSCREENSECFLG:
33013 do_getscreenSecretFlag();
33014 break;
33015 case GETSCREENLAYMAP:
33016 do_getscreenLayerMap();
33017 break;
33018 case GETSCREENLAYSCR:
33019 do_getscreenLayerscreen();
33020 break;
33021 case GETSCREENPATH:
33022 do_getscreenPath();
33023 break;
33024 case GETSCREENWARPRX:
33025 do_getscreenWarpReturnX();
33026 break;
33027 case GETSCREENWARPRY:
33028 do_getscreenWarpReturnY();
33029 break;
33030
33031 case COMBOTILE:
33032 2564 do_combotile(false);
33033 2564 break;
33034
33035 case DRAWLIGHT_CIRCLE:
33036 {
33037 static const int ARGS = 7;
33038 zfix cx = zslongToFix(SH::read_stack(ri->sp + (ARGS-1)));
33039 zfix cy = zslongToFix(SH::read_stack(ri->sp + (ARGS-2)));
33040 int radius = SH::read_stack(ri->sp + (ARGS-3));
33041 int transp_rad = SH::read_stack(ri->sp + (ARGS-4));
33042 int dith_rad = SH::read_stack(ri->sp + (ARGS-5));
33043 int dith_type = SH::read_stack(ri->sp + (ARGS-6));
33044 int dith_arg = SH::read_stack(ri->sp + (ARGS-7));
33045 if(radius >= 0) radius /= 10000;
33046 else radius = game->get_light_rad();
33047 if(!radius) break;
33048 if(transp_rad >= 0) transp_rad /= 10000;
33049 if(dith_rad >= 0) dith_rad /= 10000;
33050 if(dith_type >= 0) dith_type /= 10000;
33051 if(dith_arg >= 0) dith_arg /= 10000;
33052
33053 int32_t scrolldir = FFCore.ScrollingData[SCROLLDATA_DIR];
33054 int32_t scrollxoffs = 0, scrollyoffs = 0;
33055 switch(scrolldir)
33056 {
33057 case up:
33058 scrollyoffs = -176;
33059 break;
33060 case down:
33061 scrollyoffs = 176;
33062 break;
33063 case left:
33064 scrollxoffs = -256;
33065 break;
33066 case right:
33067 scrollxoffs = 256;
33068 break;
33069 }
33070
33071 doDarkroomCircle(cx,cy,radius,darkscr_bmp_curscr,nullptr,dith_rad,transp_rad,dith_type,dith_arg);
33072 doDarkroomCircle(cx+scrollxoffs,cy+scrollyoffs,radius,darkscr_bmp_scrollscr,nullptr,dith_rad,transp_rad,dith_type,dith_arg);
33073 break;
33074 }
33075 case DRAWLIGHT_SQUARE:
33076 {
33077 static const int ARGS = 7;
33078 zfix cx = zslongToFix(SH::read_stack(ri->sp + (ARGS-1)));
33079 zfix cy = zslongToFix(SH::read_stack(ri->sp + (ARGS-2)));
33080 int radius = SH::read_stack(ri->sp + (ARGS-3));
33081 int transp_rad = SH::read_stack(ri->sp + (ARGS-4));
33082 int dith_rad = SH::read_stack(ri->sp + (ARGS-5));
33083 int dith_type = SH::read_stack(ri->sp + (ARGS-6));
33084 int dith_arg = SH::read_stack(ri->sp + (ARGS-7));
33085 if(radius >= 0) radius /= 10000;
33086 else radius = game->get_light_rad();
33087 if(!radius) break;
33088 if(transp_rad >= 0) transp_rad /= 10000;
33089 if(dith_rad >= 0) dith_rad /= 10000;
33090 if(dith_type >= 0) dith_type /= 10000;
33091 if(dith_arg >= 0) dith_arg /= 10000;
33092
33093 int32_t scrolldir = FFCore.ScrollingData[SCROLLDATA_DIR];
33094 int32_t scrollxoffs = 0, scrollyoffs = 0;
33095 switch(scrolldir)
33096 {
33097 case up:
33098 scrollyoffs = -176;
33099 break;
33100 case down:
33101 scrollyoffs = 176;
33102 break;
33103 case left:
33104 scrollxoffs = -256;
33105 break;
33106 case right:
33107 scrollxoffs = 256;
33108 break;
33109 }
33110
33111 doDarkroomSquare(cx,cy,radius,darkscr_bmp_curscr,nullptr,dith_rad,transp_rad,dith_type,dith_arg);
33112 doDarkroomSquare(cx+scrollxoffs,cy+scrollyoffs,radius,darkscr_bmp_scrollscr,nullptr,dith_rad,transp_rad,dith_type,dith_arg);
33113 break;
33114 }
33115 case DRAWLIGHT_CONE:
33116 {
33117 static const int ARGS = 8;
33118 zfix cx = zslongToFix(SH::read_stack(ri->sp + (ARGS-1)));
33119 zfix cy = zslongToFix(SH::read_stack(ri->sp + (ARGS-2)));
33120 int dir = SH::read_stack(ri->sp + (ARGS-3)) / 10000;
33121 int radius = SH::read_stack(ri->sp + (ARGS-4));
33122 int transp_rad = SH::read_stack(ri->sp + (ARGS-5));
33123 int dith_rad = SH::read_stack(ri->sp + (ARGS-6));
33124 int dith_type = SH::read_stack(ri->sp + (ARGS-7));
33125 int dith_arg = SH::read_stack(ri->sp + (ARGS-8));
33126 if(radius >= 0) radius /= 10000;
33127 else radius = game->get_light_rad()*2;
33128 if(!radius) break;
33129 if(dir < 0) break;
33130 else dir = NORMAL_DIR(dir);
33131 if(transp_rad >= 0) transp_rad /= 10000;
33132 if(dith_rad >= 0) dith_rad /= 10000;
33133 if(dith_type >= 0) dith_type /= 10000;
33134 if(dith_arg >= 0) dith_arg /= 10000;
33135
33136 int32_t scrolldir = FFCore.ScrollingData[SCROLLDATA_DIR];
33137 int32_t scrollxoffs = 0, scrollyoffs = 0;
33138 switch(scrolldir)
33139 {
33140 case up:
33141 scrollyoffs = -176;
33142 break;
33143 case down:
33144 scrollyoffs = 176;
33145 break;
33146 case left:
33147 scrollxoffs = -256;
33148 break;
33149 case right:
33150 scrollxoffs = 256;
33151 break;
33152 }
33153
33154 doDarkroomCone(cx,cy,radius,dir,darkscr_bmp_curscr,nullptr,dith_rad,transp_rad,dith_type,dith_arg);
33155 doDarkroomCone(cx+scrollxoffs,cy+scrollyoffs,radius,dir,darkscr_bmp_scrollscr,nullptr,dith_rad,transp_rad,dith_type,dith_arg);
33156 break;
33157 }
33158
33159 case RECTR:
33160 case CIRCLER:
33161 case ARCR:
33162 case ELLIPSER:
33163 case LINER:
33164 case PUTPIXELR:
33165 case PIXELARRAYR:
33166 case TILEARRAYR:
33167 case LINESARRAY:
33168 case COMBOARRAYR:
33169 case DRAWTILER:
33170 case DRAWTILECLOAKEDR:
33171 case DRAWCOMBOR:
33172 case DRAWCOMBOCLOAKEDR:
33173 case DRAWCHARR:
33174 case DRAWINTR:
33175 case QUADR:
33176 case TRIANGLER:
33177 case QUAD3DR:
33178 case TRIANGLE3DR:
33179 case FASTTILER:
33180 case FASTCOMBOR:
33181 case DRAWSTRINGR:
33182 case DRAWSTRINGR2:
33183 case BMPDRAWSTRINGR2:
33184 case SPLINER:
33185 case BITMAPR:
33186 case BITMAPEXR:
33187 case DRAWLAYERR:
33188 case DRAWSCREENR:
33189 case POLYGONR:
33190 case FRAMER:
33191 37304357 do_drawing_command(scommand);
33192 37304357 break;
33193
33194 case BMPRECTR:
33195 case BMPCIRCLER:
33196 case BMPARCR:
33197 case BMPELLIPSER:
33198 case BMPLINER:
33199 case BMPSPLINER:
33200 case BMPPUTPIXELR:
33201 case BMPDRAWTILER:
33202 case BMPDRAWTILECLOAKEDR:
33203 case BMPDRAWCOMBOR:
33204 case BMPDRAWCOMBOCLOAKEDR:
33205 case BMPFASTTILER:
33206 case BMPFASTCOMBOR:
33207 case BMPDRAWCHARR:
33208 case BMPDRAWINTR:
33209 case BMPDRAWSTRINGR:
33210 case BMPQUADR:
33211 case BMPQUAD3DR:
33212 case BMPTRIANGLER:
33213 case BMPTRIANGLE3DR:
33214 case BMPPOLYGONR:
33215 case BMPDRAWLAYERR:
33216 case BMPDRAWLAYERSOLIDR:
33217 case BMPDRAWLAYERCFLAGR:
33218 case BMPDRAWLAYERCTYPER:
33219 case BMPDRAWLAYERCIFLAGR:
33220 case BMPDRAWLAYERSOLIDITYR:
33221 case BMPDRAWSCREENR:
33222 case BMPDRAWSCREENSOLIDR:
33223 case BMPDRAWSCREENSOLID2R:
33224 case BMPDRAWSCREENCOMBOFR:
33225 case BMPDRAWSCREENCOMBOIR:
33226 case BMPDRAWSCREENCOMBOTR:
33227 case BITMAPGETPIXEL:
33228 case BMPBLIT:
33229 case BMPBLITTO:
33230 case BMPMODE7:
33231 case WRITEBITMAP:
33232 case CLEARBITMAP:
33233 case BITMAPCLEARTOCOLOR:
33234 case BMPFRAMER:
33235 case BMPWRITETILE:
33236 case BMPDITHER:
33237 case BMPREPLCOLOR:
33238 case BMPSHIFTCOLOR:
33239 case BMPMASKDRAW:
33240 case BMPMASKDRAW2:
33241 case BMPMASKDRAW3:
33242 case BMPMASKBLIT:
33243 case BMPMASKBLIT2:
33244 case BMPMASKBLIT3:
33245 576754 do_drawing_command(scommand);
33246 576754 break;
33247 case READBITMAP:
33248 {
33249 int32_t bitref = SH::read_stack(ri->sp+2);
33250 if(user_bitmap* b = checkBitmap(bitref,"Read()",false,true))
33251 do_drawing_command(scommand);
33252 else //If the pointer isn't allocated, attempt to allocate it first
33253 {
33254 bitref = FFCore.get_free_bitmap();
33255 ri->d[rEXP2] = bitref; //Return to ptr
33256 if(bitref) SH::write_stack(ri->sp+2,bitref); //Write the ref, for the drawing command to read
33257 else break; //No ref allocated; don't enqueue the drawing command.
33258 do_drawing_command(scommand);
33259 }
33260 break;
33261 }
33262 case REGENERATEBITMAP:
33263 {
33264 26528 ri->d[rEXP2] = SH::read_stack(ri->sp+3);
33265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26528 times.
26528 if(user_bitmap* b = checkBitmap(ri->d[rEXP2],"Create()",false,true))
33266 26528 do_drawing_command(scommand);
33267 else //If the pointer isn't allocated
33268 {
33269 int32_t w = SH::read_stack(ri->sp) / 10000;
33270 int32_t h = SH::read_stack(ri->sp+1) / 10000;
33271 if ( get_qr(qr_OLDCREATEBITMAP_ARGS) )
33272 {
33273 //flip height and width
33274 h = h ^ w;
33275 w = h ^ w;
33276 h = h ^ w;
33277 }
33278
33279 ri->d[rEXP2] = FFCore.create_user_bitmap_ex(h,w,8); //Return to ptr
33280 }
33281 26528 break;
33282 }
33283
33284 case BITMAPFREE:
33285 {
33286 FFCore.do_deallocate_bitmap();
33287 break;
33288 }
33289
33290 case BITMAPOWN:
33291 {
33292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146 times.
146 if(FFCore.isSystemBitref(ri->bitmapref))
33293 break; //Don't attempt to own system bitmaps!
33294 146 user_bitmap* b = checkBitmap(ri->bitmapref, "Own()", false);
33295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146 times.
146 if(b)
33296 {
33297 146 b->own(type, i);
33298 146 }
33299 146 break;
33300 }
33301
33302 case OBJ_OWN_BITMAP:
33303 {
33304 int bmpid = get_register(sarg1);
33305 if(FFCore.isSystemBitref(bmpid))
33306 break; //Don't attempt to own system bitmaps!
33307 user_bitmap* b = checkBitmap(bmpid, nullptr, false);
33308 if(!b) break;
33309 ScriptType own_type = (ScriptType)sarg2;
33310 int32_t own_i = get_own_i(own_type);
33311 b->own(own_type,own_i);
33312 break;
33313 }
33314 case OBJ_OWN_PALDATA:
33315 {
33316 int palid = get_register(sarg1);
33317 user_paldata* pd = checkPalData(palid, nullptr, false);
33318 if(!pd) break;
33319 ScriptType own_type = (ScriptType)sarg2;
33320 int32_t own_i = get_own_i(own_type);
33321 pd->own(own_type,own_i);
33322 break;
33323 }
33324 case OBJ_OWN_FILE:
33325 {
33326 int fileid = get_register(sarg1);
33327 user_file* f = checkFile(fileid, nullptr, false);
33328 if(!f) break;
33329 ScriptType own_type = (ScriptType)sarg2;
33330 int32_t own_i = get_own_i(own_type);
33331 f->own(own_type,own_i);
33332 break;
33333 }
33334 case OBJ_OWN_DIR:
33335 {
33336 int dirid = get_register(sarg1);
33337 user_dir* dr = checkDir(dirid, nullptr, false);
33338 if(!dr) break;
33339 ScriptType own_type = (ScriptType)sarg2;
33340 int32_t own_i = get_own_i(own_type);
33341 dr->own(own_type,own_i);
33342 break;
33343 }
33344 case OBJ_OWN_STACK:
33345 {
33346 int stackid = get_register(sarg1);
33347 user_stack* st = checkStack(stackid, nullptr, false);
33348 if(!st) break;
33349 ScriptType own_type = (ScriptType)sarg2;
33350 int32_t own_i = get_own_i(own_type);
33351 st->own(own_type,own_i);
33352 break;
33353 }
33354 case OBJ_OWN_RNG:
33355 {
33356 int rngid = get_register(sarg1);
33357 user_rng* r = checkRNG(rngid, nullptr, false);
33358 if(!r) break;
33359 ScriptType own_type = (ScriptType)sarg2;
33360 int32_t own_i = get_own_i(own_type);
33361 r->own(own_type,own_i);
33362 break;
33363 }
33364 case OBJ_OWN_CLASS:
33365 {
33366 int classid = get_register(sarg1);
33367 user_object* obj = checkObject(classid, false);
33368 if(!obj) break;
33369 ScriptType own_type = (ScriptType)sarg2;
33370 int32_t own_i = get_own_i(own_type);
33371 obj->own(own_type,own_i);
33372 break;
33373 }
33374 case OBJ_OWN_ARRAY:
33375 {
33376 int arrid = get_register(sarg1)/10000;
33377 ScriptType own_type = (ScriptType)sarg2;
33378 int32_t own_i = get_own_i(own_type);
33379 do_own_array(arrid, own_type, own_i);
33380 break;
33381 }
33382
33383 case COPYTILEVV:
33384 do_copytile(true, true);
33385 break;
33386
33387 case COPYTILEVR:
33388 do_copytile(true, false);
33389 break;
33390
33391 case COPYTILERV:
33392 do_copytile(false, true);
33393 break;
33394
33395 case COPYTILERR:
33396 16962076 do_copytile(false, false);
33397 16962076 break;
33398
33399 case SWAPTILEVV:
33400 do_swaptile(true, true);
33401 break;
33402
33403 case SWAPTILEVR:
33404 do_swaptile(true, false);
33405 break;
33406
33407 case SWAPTILERV:
33408 do_swaptile(false, true);
33409 break;
33410
33411 case SWAPTILERR:
33412 do_swaptile(false, false);
33413 break;
33414
33415 case CLEARTILEV:
33416 do_cleartile(true);
33417 break;
33418
33419 case CLEARTILER:
33420 do_cleartile(false);
33421 break;
33422
33423 case OVERLAYTILEVV:
33424 do_overlaytile(true, true);
33425 break;
33426
33427 case OVERLAYTILEVR:
33428 do_overlaytile(true, false);
33429 break;
33430
33431 case OVERLAYTILERV:
33432 do_overlaytile(false, true);
33433 break;
33434
33435 case OVERLAYTILERR:
33436 57032 do_overlaytile(false, false);
33437 57032 break;
33438
33439 case FLIPROTTILEVV:
33440 do_fliprotatetile(true, true);
33441 break;
33442
33443 case FLIPROTTILEVR:
33444 do_fliprotatetile(true, false);
33445 break;
33446
33447 case FLIPROTTILERV:
33448 do_fliprotatetile(false, true);
33449 break;
33450
33451 case FLIPROTTILERR:
33452 do_fliprotatetile(false, false);
33453 break;
33454
33455 case GETTILEPIXELV:
33456 do_gettilepixel(true);
33457 break;
33458
33459 case GETTILEPIXELR:
33460 do_gettilepixel(false);
33461 break;
33462
33463 case SETTILEPIXELV:
33464 do_settilepixel(true);
33465 break;
33466
33467 case SETTILEPIXELR:
33468 do_settilepixel(false);
33469 break;
33470
33471 case SHIFTTILEVV:
33472 do_shifttile(true, true);
33473 break;
33474
33475 case SHIFTTILEVR:
33476 do_shifttile(true, false);
33477 break;
33478
33479 case SHIFTTILERV:
33480 do_shifttile(false, true);
33481 break;
33482
33483 case SHIFTTILERR:
33484 do_shifttile(false, false);
33485 break;
33486
33487 case SETRENDERTARGET:
33488 3535588 do_set_rendertarget(true);
33489 3535588 break;
33490
33491 case GAMEEND:
33492
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( using_SRAM )
33493 {
33494 Z_scripterrlog("Cannot End Game while reading or writing to SRAM. Aborting End. /n");
33495 break;
33496 }
33497 1 Quit = qQUIT;
33498 1 skipcont = 1;
33499 1 scommand = 0xFFFF;
33500 1 break;
33501 case GAMERELOAD:
33502 if ( using_SRAM )
33503 {
33504 Z_scripterrlog("Cannot Reload Game while reading or writing to SRAM. Aborting Reload. /n");
33505 break;
33506 }
33507 Quit = qRELOAD;
33508 skipcont = 1;
33509 scommand = 0xFFFF;
33510 break;
33511 case GAMESETCUSTOMCURSOR:
33512 {
33513 int32_t bmpptr = SH::read_stack(ri->sp + 4);
33514 int fx = SH::read_stack(ri->sp + 3) / 10000;
33515 int fy = SH::read_stack(ri->sp + 2) / 10000;
33516 bool recolor = SH::read_stack(ri->sp + 1)!=0;
33517 bool scale = SH::read_stack(ri->sp + 0)!=0;
33518 if(user_bitmap* b = checkBitmap(bmpptr,nullptr,true))
33519 {
33520 custom_mouse(b->u_bmp,fx,fy,recolor,scale);
33521 }
33522 break;
33523 }
33524
33525 case GAMECONTINUE:
33526 if ( using_SRAM )
33527 {
33528 Z_scripterrlog("Cannot Continue Game while reading or writing to SRAM. Aborting Continue. /n");
33529 break;
33530 }
33531 reset_combo_animations();
33532 reset_combo_animations2();
33533
33534 Quit = qCONT;
33535 skipcont = 1;
33536 //cont_game();
33537 scommand = 0xFFFF;
33538 break;
33539
33540 case GAMESAVEQUIT:
33541 if ( using_SRAM )
33542 {
33543 Z_scripterrlog("Cannot Save Game while reading or writing to SRAM. Aborting Save. /n");
33544 break;
33545 }
33546 Quit = qSAVE;
33547 skipcont = 1;
33548 scommand =0xFFFF;
33549 break;
33550
33551 case GAMESAVECONTINUE:
33552 Quit = qSAVECONT;
33553 skipcont = 1;
33554 scommand =0xFFFF;
33555 break;
33556
33557 case SAVE:
33558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if ( using_SRAM )
33559 {
33560 Z_scripterrlog("Cannot Save Game while reading or writing to SRAM. Aborting Save. /n");
33561 break;
33562 }
33563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(scriptCanSave)
33564 {
33565 11 save_game(false);
33566 11 scriptCanSave=false;
33567 11 }
33568 11 break;
33569
33570 case SAVESCREEN:
33571 do_showsavescreen();
33572 break;
33573
33574 case SHOWF6SCREEN:
33575 onTryQuit();
33576 break;
33577
33578 case SAVEQUITSCREEN:
33579 save_game(false, 1);
33580 break;
33581
33582 //Not Implemented
33583 case ELLIPSE2:
33584 case FLOODFILL:
33585 break;
33586
33587 case SETCOLORB:
33588 case SETDEPTHB:
33589 case GETCOLORB:
33590 case GETDEPTHB:
33591 break;
33592
33593 case ENQUEUER:
33594 do_enqueue(false);
33595 break;
33596
33597 case ENQUEUEV:
33598 do_enqueue(true);
33599 break;
33600
33601 case DEQUEUE:
33602 do_dequeue(false);
33603 break;
33604
33605 //Visual Effects
33606 case WAVYIN:
33607 FFScript::do_wavyin();
33608 break;
33609 case WAVYOUT:
33610 FFScript::do_wavyout();
33611 break;
33612 case ZAPIN:
33613 FFScript::do_zapin();
33614 break;
33615 case ZAPOUT:
33616 FFScript::do_zapout();
33617 break;
33618 case OPENWIPE:
33619 {
33620 FFScript::do_openscreen();
33621 break;
33622 }
33623 case CLOSEWIPE:
33624 {
33625 FFScript::do_closescreen();
33626 break;
33627 }
33628 case OPENWIPESHAPE:
33629 {
33630 FFScript::do_openscreenshape();
33631 break;
33632 }
33633 case CLOSEWIPESHAPE:
33634 {
33635 FFScript::do_closescreenshape();
33636 break;
33637 }
33638
33639 //Monochrome
33640 case GREYSCALEON:
33641 setMonochrome(true);
33642 break;
33643 case GREYSCALEOFF:
33644 setMonochrome(false);
33645 break;
33646
33647 case TINT:
33648 {
33649 FFCore.Tint();
33650 break;
33651 }
33652
33653 case CLEARTINT:
33654 {
33655 FFCore.clearTint();
33656 break;
33657 }
33658
33659 case MONOHUE:
33660 {
33661 FFCore.gfxmonohue();
33662 break;
33663 }
33664
33665 case SCREENDOSPAWN:
33666 {
33667 ri->d[rEXP1] = scriptloadenemies() ? 10000 : 0;
33668 break;
33669 }
33670
33671 case SCRTRIGGERCOMBO:
33672 {
33673 int32_t lyr = get_register(sarg1) / 10000;
33674 int32_t pos = get_register(sarg2) / 10000;
33675 set_register(sarg1, do_trigger_combo(lyr,pos) ? 10000 : 0);
33676 break;
33677 }
33678
33679 case SWITCHNPC:
33680 {
33681 byte effect = vbound(get_register(sarg1)/10000, 0, 255);
33682 set_register(sarg1,0);
33683 if(Hero.switchhookclk) break; //Already switching!
33684 if(GuyH::loadNPC(ri->guyref, "npc->Switch()") == SH::_NoError)
33685 {
33686 switching_object = guys.spr(GuyH::getNPCIndex(ri->guyref));
33687 hooked_combopos = -1;
33688 hooked_layerbits = 0;
33689 switching_object->switch_hooked = true;
33690 Hero.doSwitchHook(effect);
33691 set_register(sarg1,10000);
33692 }
33693 break;
33694 }
33695
33696 case SWITCHITM:
33697 {
33698 byte effect = vbound(get_register(sarg1)/10000, 0, 255);
33699 set_register(sarg1,0);
33700 if(Hero.switchhookclk) break; //Already switching!
33701 if(ItemH::loadItem(ri->itemref, "item->Switch()") == SH::_NoError)
33702 {
33703 switching_object = items.spr(ItemH::getItemIndex(ri->itemref));
33704 hooked_combopos = -1;
33705 hooked_layerbits = 0;
33706 switching_object->switch_hooked = true;
33707 Hero.doSwitchHook(effect);
33708 set_register(sarg1,10000);
33709 }
33710 break;
33711 }
33712
33713 case SWITCHLW:
33714 {
33715 byte effect = vbound(get_register(sarg1)/10000, 0, 255);
33716 set_register(sarg1,0);
33717 if(Hero.switchhookclk) break; //Already switching!
33718 if(LwpnH::loadWeapon(ri->lwpn, "lweapon->Switch()") == SH::_NoError)
33719 {
33720 switching_object = Lwpns.spr(LwpnH::getLWeaponIndex(ri->lwpn));
33721 hooked_combopos = -1;
33722 hooked_layerbits = 0;
33723 switching_object->switch_hooked = true;
33724 Hero.doSwitchHook(effect);
33725 set_register(sarg1,10000);
33726 }
33727 break;
33728 }
33729
33730 case SWITCHEW:
33731 {
33732 byte effect = vbound(get_register(sarg1)/10000, 0, 255);
33733 set_register(sarg1,0);
33734 if(Hero.switchhookclk) break; //Already switching!
33735 if(EwpnH::loadWeapon(ri->ewpn, "eweapon->Switch()") == SH::_NoError)
33736 {
33737 switching_object = Ewpns.spr(EwpnH::getEWeaponIndex(ri->lwpn));
33738 hooked_combopos = -1;
33739 hooked_layerbits = 0;
33740 switching_object->switch_hooked = true;
33741 Hero.doSwitchHook(effect);
33742 set_register(sarg1,10000);
33743 }
33744 break;
33745 }
33746
33747 case SWITCHCMB:
33748 {
33749 int32_t pos = get_register(sarg1)/10000;
33750 set_register(sarg1,0);
33751 if(Hero.switchhookclk) break; //Already switching!
33752 if(unsigned(pos) > 176)
33753 break;
33754 switching_object = NULL;
33755 hooked_combopos = pos;
33756 hooked_layerbits = 0;
33757 Hero.doSwitchHook(get_register(sarg2)/10000);
33758 if(!hooked_layerbits) //failed
33759 Hero.reset_hookshot();
33760 else set_register(sarg1,10000); //success return
33761 break;
33762 }
33763
33764 case LINKWARPEXR:
33765 {
33766 16 FFCore.do_warp_ex(false);
33767 16 break;
33768 }
33769
33770 case KILLPLAYER:
33771 {
33772 Hero.kill(get_register(sarg1));
33773 break;
33774 }
33775
33776 case HEROMOVEXY:
33777 {
33778 zfix dx = zslongToFix(SH::read_stack(ri->sp + 4));
33779 zfix dy = zslongToFix(SH::read_stack(ri->sp + 3));
33780 bool kb = SH::read_stack(ri->sp + 2)!=0;
33781 bool ign_sv = SH::read_stack(ri->sp + 1)!=0;
33782 bool shove = SH::read_stack(ri->sp + 0)!=0;
33783 ri->d[rEXP1] = Hero.movexy(dx, dy, kb, ign_sv, shove) ? 10000 : 0;
33784 break;
33785 }
33786 case HEROCANMOVEXY:
33787 {
33788 zfix dx = zslongToFix(SH::read_stack(ri->sp + 4));
33789 zfix dy = zslongToFix(SH::read_stack(ri->sp + 3));
33790 bool kb = SH::read_stack(ri->sp + 2)!=0;
33791 bool ign_sv = SH::read_stack(ri->sp + 1)!=0;
33792 bool shove = SH::read_stack(ri->sp + 0)!=0;
33793 ri->d[rEXP1] = Hero.can_movexy(dx, dy, kb, ign_sv, shove) ? 10000 : 0;
33794 break;
33795 }
33796 case HEROMOVEATANGLE:
33797 {
33798 zfix degrees = zslongToFix(SH::read_stack(ri->sp + 4));
33799 zfix pxamnt = zslongToFix(SH::read_stack(ri->sp + 3));
33800 bool kb = SH::read_stack(ri->sp + 2)!=0;
33801 bool ign_sv = SH::read_stack(ri->sp + 1)!=0;
33802 bool shove = SH::read_stack(ri->sp + 0)!=0;
33803 ri->d[rEXP1] = Hero.moveAtAngle(degrees, pxamnt, kb, ign_sv, shove) ? 10000 : 0;
33804 break;
33805 }
33806 case HEROCANMOVEATANGLE:
33807 {
33808 zfix degrees = zslongToFix(SH::read_stack(ri->sp + 4));
33809 zfix pxamnt = zslongToFix(SH::read_stack(ri->sp + 3));
33810 bool kb = SH::read_stack(ri->sp + 2)!=0;
33811 bool ign_sv = SH::read_stack(ri->sp + 1)!=0;
33812 bool shove = SH::read_stack(ri->sp + 0)!=0;
33813 ri->d[rEXP1] = Hero.can_moveAtAngle(degrees, pxamnt, kb, ign_sv, shove) ? 10000 : 0;
33814 break;
33815 }
33816 case HEROMOVE:
33817 {
33818 int dir = SH::read_stack(ri->sp + 4)/10000;
33819 zfix pxamnt = zslongToFix(SH::read_stack(ri->sp + 3));
33820 bool kb = SH::read_stack(ri->sp + 2)!=0;
33821 bool ign_sv = SH::read_stack(ri->sp + 1)!=0;
33822 bool shove = SH::read_stack(ri->sp + 0)!=0;
33823 ri->d[rEXP1] = Hero.moveDir(dir, pxamnt, kb, ign_sv, shove) ? 10000 : 0;
33824 break;
33825 }
33826 case HEROCANMOVE:
33827 {
33828 int dir = SH::read_stack(ri->sp + 4)/10000;
33829 zfix pxamnt = zslongToFix(SH::read_stack(ri->sp + 3));
33830 bool kb = SH::read_stack(ri->sp + 2)!=0;
33831 bool ign_sv = SH::read_stack(ri->sp + 1)!=0;
33832 bool shove = SH::read_stack(ri->sp + 0)!=0;
33833 ri->d[rEXP1] = Hero.can_moveDir(dir, pxamnt, kb, ign_sv, shove) ? 10000 : 0;
33834 break;
33835 }
33836 case HEROLIFTRELEASE:
33837 {
33838 if(Hero.lift_wpn)
33839 {
33840 ri->d[rEXP1] = Hero.lift_wpn->getUID();
33841 Lwpns.add(Hero.lift_wpn);
33842 Hero.lift_wpn = nullptr;
33843 }
33844 else ri->d[rEXP1] = 0;
33845 break;
33846 }
33847 case HEROLIFTGRAB:
33848 {
33849 auto lwuid = SH::read_stack(ri->sp + 2);
33850 auto lifttime = SH::read_stack(ri->sp + 1)/10000;
33851 auto liftheight = zslongToFix(SH::read_stack(ri->sp + 0));
33852 if(weapon* wpn = checkLWpn(lwuid,"Hero->Lift()"))
33853 {
33854 Hero.lift(wpn, lifttime, liftheight);
33855 if(Lwpns.find(wpn) > -1)
33856 Lwpns.remove(wpn);
33857 if(type == ScriptType::Lwpn && lwuid == i)
33858 earlyretval = RUNSCRIPT_SELFREMOVE;
33859 }
33860 break;
33861 }
33862 case LOADPORTAL:
33863 {
33864 auto val = get_register(sarg1)/10000;
33865 if(val != -1)
33866 {
33867 portal* prt = (portal*)portals.spr(val);
33868 if(prt)
33869 val = prt->getUID();
33870 else
33871 {
33872 Z_scripterrlog("Tried to load invalid portal index '%d'\n", val);
33873 val = 0;
33874 }
33875 }
33876 ri->portalref = ri->d[rEXP1] = val;
33877 break;
33878 }
33879 case CREATEPORTAL:
33880 {
33881 portal* p = new portal();
33882 if(portals.add(p))
33883 ri->portalref = ri->d[rEXP1] = p->getUID();
33884 else
33885 {
33886 ri->portalref = ri->d[rEXP1] = 0;
33887 Z_scripterrlog("Unable to create new portal! Limit reached!\n");
33888 }
33889 break;
33890 }
33891 case LOADSAVPORTAL:
33892 {
33893 auto val = get_register(sarg1)/10000;
33894 savedportal* prt = checkSavedPortal(val,"Game->LoadSavedPortal");
33895 ri->saveportalref = ri->d[rEXP1] = prt ? val : 0;
33896 break;
33897 }
33898 case CREATESAVPORTAL:
33899 {
33900 if(game->user_portals.size() >= MAX_SAVED_PORTALS)
33901 {
33902 ri->saveportalref = ri->d[rEXP1] = 0;
33903 Z_scripterrlog("Cannot create any more Saved Portals! Remove some first!\n");
33904 break;
33905 }
33906 savedportal& ref = game->user_portals.emplace_back();
33907 ri->saveportalref = ri->d[rEXP1] = ref.getUID();
33908 break;
33909 }
33910 case PORTALREMOVE:
33911 {
33912 if(portal* p = checkPortal(ri->portalref, "Remove", true))
33913 {
33914 if(p == &mirror_portal)
33915 p->clear();
33916 else
33917 {
33918 auto id = portals.find(p);
33919 if(id > -1)
33920 portals.del(id,true);
33921 }
33922 }
33923 break;
33924 }
33925 case PORTALUSESPRITE:
33926 do_portalusesprite();
33927 break;
33928 case SAVEDPORTALREMOVE:
33929 {
33930 if(savedportal* sp = checkSavedPortal(ri->saveportalref, "Remove", true))
33931 {
33932 if(sp == &(game->saved_mirror_portal))
33933 sp->clear();
33934 else
33935 {
33936 //ensure all pointers to the object are cleared before deleting
33937 portals.forEach([&](sprite& spr)
33938 {
33939 portal* tmp = (portal*)&spr;
33940 if(sp->getUID() == tmp->saved_data)
33941 {
33942 tmp->saved_data = 0;
33943 }
33944 return false;
33945 });
33946 //delete the savedportal object from the vector
33947 for(auto it = game->user_portals.begin();
33948 it != game->user_portals.end();)
33949 {
33950 savedportal& tmp = *it;
33951 if(sp == &tmp)
33952 {
33953 game->user_portals.erase(it);
33954 break;
33955 }
33956 else ++it;
33957 }
33958 }
33959 }
33960 break;
33961 }
33962 case SAVEDPORTALGENERATE:
33963 {
33964 auto retval = 0;
33965 if(savedportal* sp = checkSavedPortal(ri->saveportalref, "Generate"))
33966 {
33967 retval = getPortalFromSaved(sp);
33968 if(!retval)
33969 {
33970 if(portal* p = loadportal(*sp))
33971 if(portals.add(p))
33972 retval = p->getUID();
33973 }
33974 }
33975 ri->d[rEXP1] = retval;
33976 break;
33977 }
33978
33979 case LINKEXPLODER:
33980 {
33981 int32_t mode = get_register(sarg1) / 10000;
33982 if ( (unsigned) mode > 2 )
33983 {
33984 Z_scripterrlog("Invalid mode (%d) passed to Player->Explode(int32_t mode)\n",mode);
33985 }
33986 else Hero.explode(mode);
33987 break;
33988 }
33989 case NPCEXPLODER:
33990 {
33991
33992 int32_t mode = get_register(sarg1) / 10000;
33993 al_trace("Called npc->Explode(%d), for enemy index %u\n", mode, ri->guyref);
33994 if ( (unsigned) mode > 2 )
33995 {
33996 Z_scripterrlog("Invalid mode (%d) passed to npc->Explode(int32_t mode)\n",mode);
33997 }
33998 else
33999 {
34000 if(GuyH::loadNPC(ri->guyref, "npc->Explode()") == SH::_NoError)
34001 {
34002 al_trace("npc->Explode() is loading the npc into a pointer.\n");
34003 //enemy *e = (enemy*)guys.spr(ri->guyref);
34004 al_trace("npc->Explode() is calling enemy::explode.\n");
34005 //(enemy *) guys.explode(eid);
34006 //e->explode(mode);
34007 //enemy *en=GuyH::getNPC();
34008 //en->stop_bgsfx(GuyH::getNPCIndex(ri->guyref));
34009 guys.spr(GuyH::getNPCIndex(ri->guyref))->explode(mode);
34010 }
34011 }
34012 break;
34013 }
34014
34015 case ITEMEXPLODER:
34016 {
34017
34018 int32_t mode = get_register(sarg1) / 10000;
34019 al_trace("Called item->Explode(%d), for item index %u\n", mode, ri->itemref);
34020 if ( (unsigned) mode > 2 )
34021 {
34022 Z_scripterrlog("Invalid mode (%d) passed to item->Explode(int32_t mode)\n",mode);
34023 }
34024 else
34025 {
34026 if(ItemH::loadItem(ri->itemref, "item->Explode()") == SH::_NoError)
34027 {
34028 items.spr(ItemH::getItemIndex(ri->itemref))->explode(mode);
34029 }
34030 }
34031 break;
34032 }
34033 case LWEAPONEXPLODER:
34034 {
34035
34036 int32_t mode = get_register(sarg1) / 10000;
34037 al_trace("Called lweapon->Explode(%d), for lweapon index %u\n", mode, ri->lwpn);
34038 if ( (unsigned) mode > 2 )
34039 {
34040 Z_scripterrlog("Invalid mode (%d) passed to lweapon->Explode(int32_t mode)\n",mode);
34041 }
34042 else
34043 {
34044 if(LwpnH::loadWeapon(ri->lwpn, "lweapon->Explode()") == SH::_NoError)
34045 {
34046 Lwpns.spr(LwpnH::getLWeaponIndex(ri->lwpn))->explode(mode);
34047 }
34048 }
34049 break;
34050 }
34051 case EWEAPONEXPLODER:
34052 {
34053
34054 int32_t mode = get_register(sarg1) / 10000;
34055 al_trace("Called eweapon->Explode(%d), for eweapon index %u\n", mode, ri->ewpn);
34056 if ( (unsigned) mode > 2 )
34057 {
34058 Z_scripterrlog("Invalid mode (%d) passed to eweapon->Explode(int32_t mode)\n",mode);
34059 }
34060 else
34061 {
34062 if(EwpnH::loadWeapon(ri->ewpn, "eweapon->Explode()") == SH::_NoError)
34063 {
34064 Ewpns.spr(EwpnH::getEWeaponIndex(ri->lwpn))->explode(mode);
34065 }
34066 }
34067 break;
34068 }
34069
34070 case BOTTLENAMEGET:
34071 {
34072 int32_t arrayptr = get_register(sarg1) / 10000;
34073 int32_t id = ri->bottletyperef-1;
34074 if(unsigned(id) > 63)
34075 {
34076 Z_scripterrlog("Invalid bottledata ID (%d) passed to bottledata->GetName().\n", id);
34077 break;
34078 }
34079
34080 if(ArrayH::setArray(arrayptr, QMisc.bottle_types[id].name) == SH::_Overflow)
34081 Z_scripterrlog("Array supplied to 'bottledata->GetName()' not large enough\n");
34082 break;
34083 }
34084 case BOTTLENAMESET:
34085 {
34086 int32_t arrayptr = get_register(sarg1) / 10000;
34087 int32_t id = ri->bottletyperef-1;
34088 if(unsigned(id) > 63)
34089 {
34090 Z_scripterrlog("Invalid bottledata ID (%d) passed to bottledata->SetName().\n", id+1);
34091 break;
34092 }
34093 string name;
34094 ArrayH::getString(arrayptr, name, 31);
34095 strcpy(QMisc.bottle_types[id].name, name.c_str());
34096 break;
34097 }
34098 case BSHOPNAMEGET:
34099 {
34100 int32_t arrayptr = get_register(sarg1) / 10000;
34101 int32_t id = ri->bottleshopref-1;
34102 if(unsigned(id) > 255)
34103 {
34104 Z_scripterrlog("Invalid bottleshopdata ID (%d) passed to bottleshopdata->GetName().\n", id+1);
34105 break;
34106 }
34107
34108 if(ArrayH::setArray(arrayptr, QMisc.bottle_shop_types[id].name) == SH::_Overflow)
34109 Z_scripterrlog("Array supplied to 'bottleshopdata->GetName()' not large enough\n");
34110 break;
34111 }
34112 case BSHOPNAMESET:
34113 {
34114 int32_t arrayptr = get_register(sarg1) / 10000;
34115 int32_t id = ri->bottleshopref;
34116 if(unsigned(id) > 255)
34117 {
34118 Z_scripterrlog("Invalid bottleshopdata ID (%d) passed to bottleshopdata->SetName().\n", id);
34119 break;
34120 }
34121 string name;
34122 ArrayH::getString(arrayptr, name, 31);
34123 strcpy(QMisc.bottle_shop_types[id].name, name.c_str());
34124 break;
34125 }
34126
34127 case RUNITEMSCRIPT:
34128 {
34129 15 int32_t itemid = ri->idata;
34130
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 if(unsigned(itemid) > MAXITEMS) break;
34131 15 int32_t mode = get_register(sarg1) / 10000;
34132 // zprint("Trying to run the script on item: %d\n",itemid);
34133 // zprint("The script ID is: %d\n",itemsbuf[itemid].script);
34134 // zprint("Runitemscript mode is: %d\n", mode);
34135 15 auto& data = get_script_engine_data(ScriptType::Item, itemid);
34136
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
15 switch(mode)
34137 {
34138 case 0:
34139 {
34140 data.doscript = 4;
34141 break;
34142 }
34143 case 1:
34144 {
34145 if ( itemsbuf[itemid].script != 0 ) //&& !data.doscript )
34146 {
34147 if ( !data.doscript )
34148 {
34149 data.ref.Clear();
34150 data.doscript = 1;
34151 //ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[itemid].script, itemid);
34152 }
34153 else
34154 {
34155 //Emily, clear the stack here, clear refinfo, and set up to run again on the next frame from the beginning.
34156 }
34157 }
34158 break;
34159 }
34160 15 case 2:
34161 default:
34162 {
34163
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 if ( itemsbuf[itemid].script != 0 ) //&& !data.doscript )
34164 {
34165
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 if (data.doscript != 2 )data.doscript = 2;
34166 15 }
34167 15 break;
34168 }
34169 /*
34170 case 0:
34171 {
34172 data.doscript = 0;
34173 break;
34174 }
34175 default:
34176 {
34177
34178 if ( itemsbuf[itemid].script != 0 ) //&& !data.doscript )
34179 {
34180 //itemScriptData[itemid].Clear();
34181 //for ( int32_t q = 0; q < 1024; q++ ) item_stack[itemid][q] = 0;
34182 //ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[itemid].script, itemid & 0xFFF);
34183 data.doscript = 2;
34184 }
34185 break;
34186 }
34187 */
34188 }
34189 15 break;
34190 }
34191
34192 //case NPCData
34193
34194 case GETNPCDATATILE: FFScript::getNPCData_tile(); break;
34195 case GETNPCDATAEHEIGHT: FFScript::getNPCData_e_height(); break;
34196 case GETNPCDATAFLAGS: FFScript::getNPCData_flags(); break;
34197 case GETNPCDATAFLAGS2: FFScript::getNPCData_flags2(); break;
34198 case GETNPCDATAWIDTH: FFScript::getNPCData_flags2(); break;
34199 case GETNPCDATAHEIGHT: FFScript::getNPCData_flags2(); break;
34200 case GETNPCDATASTILE: FFScript::getNPCData_s_tile(); break;
34201 case GETNPCDATASWIDTH: FFScript::getNPCData_s_width(); break;
34202 case GETNPCDATASHEIGHT: FFScript::getNPCData_s_height(); break;
34203 case GETNPCDATAETILE: FFScript::getNPCData_e_tile(); break;
34204 case GETNPCDATAEWIDTH: FFScript::getNPCData_e_width(); break;
34205 case GETNPCDATAHP: FFScript::getNPCData_hp(); break;
34206 case GETNPCDATAFAMILY: FFScript::getNPCData_family(); break;
34207 case GETNPCDATACSET: FFScript::getNPCData_cset(); break;
34208 case GETNPCDATAANIM: FFScript::getNPCData_anim(); break;
34209 case GETNPCDATAEANIM: FFScript::getNPCData_e_anim(); break;
34210 case GETNPCDATAFRAMERATE: FFScript::getNPCData_frate(); break;
34211 case GETNPCDATAEFRAMERATE: FFScript::getNPCData_e_frate(); break;
34212 case GETNPCDATATOUCHDMG: FFScript::getNPCData_dp(); break;
34213 case GETNPCDATAWPNDAMAGE: FFScript::getNPCData_wdp(); break;
34214 case GETNPCDATAWEAPON: FFScript::getNPCData_wdp(); break;
34215 case GETNPCDATARANDOM: FFScript::getNPCData_rate(); break;
34216 case GETNPCDATAHALT: FFScript::getNPCData_hrate(); break;
34217 case GETNPCDATASTEP: FFScript::getNPCData_step(); break;
34218 case GETNPCDATAHOMING: FFScript::getNPCData_homing(); break;
34219 case GETNPCDATAHUNGER: FFScript::getNPCData_grumble(); break;
34220 case GETNPCDATADROPSET: FFScript::getNPCData_item_set(); break;
34221 case GETNPCDATABGSFX: FFScript::getNPCData_bgsfx(); break;
34222 case GETNPCDATADEATHSFX: FFScript::getNPCData_deadsfx(); break;
34223 case GETNPCDATAXOFS: FFScript::getNPCData_xofs(); break;
34224 case GETNPCDATAYOFS: FFScript::getNPCData_yofs(); break;
34225 case GETNPCDATAZOFS: FFScript::getNPCData_zofs(); break;
34226 case GETNPCDATAHXOFS: FFScript::getNPCData_hxofs(); break;
34227 case GETNPCDATAHYOFS: FFScript::getNPCData_hyofs(); break;
34228 case GETNPCDATAHITWIDTH: FFScript::getNPCData_hxsz(); break;
34229 case GETNPCDATAHITHEIGHT: FFScript::getNPCData_hysz(); break;
34230 case GETNPCDATAHITZ: FFScript::getNPCData_hzsz(); break;
34231 case GETNPCDATATILEWIDTH: FFScript::getNPCData_txsz(); break;
34232 case GETNPCDATATILEHEIGHT: FFScript::getNPCData_tysz(); break;
34233 case GETNPCDATAWPNSPRITE: FFScript::getNPCData_wpnsprite(); break;
34234 //case GETNPCDATASCRIPTDEF: FFScript::getNPCData_scriptdefence(); break; //2.future cross-compat.
34235 case GETNPCDATADEFENSE: FFScript::getNPCData_defense(); break;
34236 case GETNPCDATASIZEFLAG: FFScript::getNPCData_SIZEflags(); break;
34237 case GETNPCDATAATTRIBUTE: FFScript::getNPCData_misc(); break;
34238 case GETNPCDATAHITSFX: FFScript::getNPCData_hitsfx(); break;
34239
34240 case SETNPCDATAFLAGS: FFScript::setNPCData_flags(); break;
34241 case SETNPCDATAFLAGS2: FFScript::setNPCData_flags2(); break;
34242 case SETNPCDATAWIDTH: FFScript::setNPCData_width(); break;
34243 case SETNPCDATAHEIGHT: FFScript::setNPCData_height(); break;
34244 case SETNPCDATASTILE: FFScript::setNPCData_s_tile(); break;
34245 case SETNPCDATASWIDTH: FFScript::setNPCData_s_width(); break;
34246 case SETNPCDATASHEIGHT: FFScript::setNPCData_s_height(); break;
34247 case SETNPCDATAETILE: FFScript::setNPCData_e_tile(); break;
34248 case SETNPCDATAEWIDTH: FFScript::setNPCData_e_width(); break;
34249 case SETNPCDATAHP: FFScript::setNPCData_hp(); break;
34250 case SETNPCDATAFAMILY: FFScript::setNPCData_family(); break;
34251 case SETNPCDATACSET: FFScript::setNPCData_cset(); break;
34252 case SETNPCDATAANIM: FFScript::setNPCData_anim(); break;
34253 case SETNPCDATAEANIM: FFScript::setNPCData_e_anim(); break;
34254 case SETNPCDATAFRAMERATE: FFScript::setNPCData_frate(); break;
34255 case SETNPCDATAEFRAMERATE: FFScript::setNPCData_e_frate(); break;
34256 case SETNPCDATATOUCHDMG: FFScript::setNPCData_dp(); break;
34257 case SETNPCDATAWPNDAMAGE: FFScript::setNPCData_wdp(); break;
34258 case SETNPCDATAWEAPON: FFScript::setNPCData_weapon(); break;
34259 case SETNPCDATARANDOM: FFScript::setNPCData_rate(); break;
34260 case SETNPCDATAHALT: FFScript::setNPCData_hrate(); break;
34261 case SETNPCDATASTEP: FFScript::setNPCData_step(); break;
34262 case SETNPCDATAHOMING: FFScript::setNPCData_homing(); break;
34263 case SETNPCDATAHUNGER: FFScript::setNPCData_grumble(); break;
34264 case SETNPCDATADROPSET: FFScript::setNPCData_item_set(); break;
34265 case SETNPCDATABGSFX: FFScript::setNPCData_bgsfx(); break;
34266 case SETNPCDATADEATHSFX: FFScript::setNPCData_hitsfx(); break;
34267 case SETNPCDATAXOFS: FFScript::setNPCData_xofs(); break;
34268 case SETNPCDATAYOFS: FFScript::setNPCData_yofs(); break;
34269 case SETNPCDATAZOFS: FFScript::setNPCData_zofs(); break;
34270 case SETNPCDATAHXOFS: FFScript::setNPCData_hxofs(); break;
34271 case SETNPCDATAHYOFS: FFScript::setNPCData_hyofs(); break;
34272 case SETNPCDATAHITWIDTH: FFScript::setNPCData_hxsz(); break;
34273 case SETNPCDATAHITHEIGHT: FFScript::setNPCData_hysz(); break;
34274 case SETNPCDATAHITZ: FFScript::setNPCData_hzsz(); break;
34275 case SETNPCDATATILEWIDTH: FFScript::setNPCData_txsz(); break;
34276 case SETNPCDATATILEHEIGHT: FFScript::setNPCData_tysz(); break;
34277 case SETNPCDATAWPNSPRITE: FFScript::setNPCData_wpnsprite(); break;
34278 case SETNPCDATAHITSFX: FFScript::setNPCData_hitsfx(); break;
34279 case SETNPCDATATILE: FFScript::setNPCData_tile(); break;
34280 case SETNPCDATAEHEIGHT: FFScript::setNPCData_e_height(); break;
34281
34282
34283
34284
34285
34286
34287 //case SETNPCDATASCRIPTDEF : FFScript::setNPCData_scriptdefence(); break;
34288 case SETNPCDATADEFENSE : FFScript::setNPCData_defense(ri->d[rEXP1]); break;
34289 case SETNPCDATASIZEFLAG : FFScript::setNPCData_SIZEflags(ri->d[rEXP1]); break;
34290 case SETNPCDATAATTRIBUTE : FFScript::setNPCData_misc(ri->d[rEXP1]); break;
34291
34292
34293 //ComboData
34294
34295 case GCDBLOCKENEM: FFScript::getComboData_block_enemies(); break;
34296 case GCDBLOCKHOLE: FFScript::getComboData_block_hole(); break;
34297 case GCDBLOCKTRIG: FFScript::getComboData_block_trigger(); break;
34298 case GCDCONVEYSPDX: FFScript::getComboData_conveyor_x_speed(); break;
34299 case GCDCONVEYSPDY: FFScript::getComboData_conveyor_y_speed(); break;
34300 case GCDCREATEENEM: FFScript::getComboData_create_enemy(); break;
34301 case GCDCREATEENEMWH: FFScript::getComboData_create_enemy_when(); break;
34302 case GCDCREATEENEMCH: FFScript::getComboData_create_enemy_change(); break;
34303 case GCDDIRCHTYPE: FFScript::getComboData_directional_change_type(); break;
34304 case GCDDISTCHTILES: FFScript::getComboData_distance_change_tiles(); break;
34305 case GCDDIVEITEM: FFScript::getComboData_dive_item(); break;
34306 case GCDDOCK: FFScript::getComboData_dock(); break;
34307 case GCDFAIRY: FFScript::getComboData_fairy(); break;
34308 case GCDFFCOMBOATTRIB: FFScript::getComboData_ff_combo_attr_change(); break;
34309 case GCDFOOTDECOTILE: FFScript::getComboData_foot_decorations_tile(); break;
34310 case GCDFOOTDECOTYPE: FFScript::getComboData_foot_decorations_type(); break;
34311 case GCDHOOKSHOTGRAB: FFScript::getComboData_hookshot_grab_point(); break;
34312 case GCDLADDERPASS: FFScript::getComboData_ladder_pass(); break;
34313 case GCDLOCKBLOCKTYPE: FFScript::getComboData_lock_block_type(); break;
34314 case GCDLOCKBLOCKCHANGE: FFScript::getComboData_lock_block_change(); break;
34315 case GCDMAGICMIRRORTYPE: FFScript::getComboData_magic_mirror_type(); break;
34316 case GCDMODIFYHPAMOUNT: FFScript::getComboData_modify_hp_amount(); break;
34317 case GCDMODIFYHPDELAY: FFScript::getComboData_modify_hp_delay(); break;
34318 case GCDMODIFYHPTYPE: FFScript::getComboData_modify_hp_type(); break;
34319 case GCDMODIFYMPAMOUNT: FFScript::getComboData_modify_mp_amount(); break;
34320 case GCDMODIFYMPDELAY: FFScript::getComboData_modify_mp_delay(); break;
34321 case GCDMODIFYMPTYPE: FFScript::getComboData_modify_mp_type(); break;
34322 case GCDNOPUSHBLOCKS: FFScript::getComboData_no_push_blocks(); break;
34323 case GCDOVERHEAD: FFScript::getComboData_overhead(); break;
34324 case GCDPLACEENEMY: FFScript::getComboData_place_enemy(); break;
34325 case GCDPUSHDIR: FFScript::getComboData_push_direction(); break;
34326 case GCDPUSHWEIGHT: FFScript::getComboData_push_weight(); break;
34327 case GCDPUSHWAIT: FFScript::getComboData_push_wait(); break;
34328 case GCDPUSHED: FFScript::getComboData_pushed(); break;
34329 case GCDRAFT: FFScript::getComboData_raft(); break;
34330 case GCDRESETROOM: FFScript::getComboData_reset_room(); break;
34331 case GCDSAVEPOINT: FFScript::getComboData_save_point_type(); break;
34332 case GCDSCREENFREEZE: FFScript::getComboData_screen_freeze_type(); break;
34333 case GCDSECRETCOMBO: FFScript::getComboData_secret_combo(); break;
34334 case GCDSINGULAR: FFScript::getComboData_singular(); break;
34335 case GCDSLOWMOVE: FFScript::getComboData_slow_movement(); break;
34336 case GCDSTATUE: FFScript::getComboData_statue_type(); break;
34337 case GCDSTEPTYPE: FFScript::getComboData_step_type(); break;
34338 case GCDSTEPCHANGETO: FFScript::getComboData_step_change_to(); break;
34339 case GCDSTRIKEREMNANTS: FFScript::getComboData_strike_remnants(); break;
34340 case GCDSTRIKEREMNANTSTYPE: FFScript::getComboData_strike_remnants_type(); break;
34341 case GCDSTRIKECHANGE: FFScript::getComboData_strike_change(); break;
34342 case GCDSTRIKECHANGEITEM: FFScript::getComboData_strike_item(); break;
34343 case GCDTOUCHITEM: FFScript::getComboData_touch_item(); break;
34344 case GCDTOUCHSTAIRS: FFScript::getComboData_touch_stairs(); break;
34345 case GCDTRIGGERTYPE: FFScript::getComboData_trigger_type(); break;
34346 case GCDTRIGGERSENS: FFScript::getComboData_trigger_sensitive(); break;
34347 case GCDWARPTYPE: FFScript::getComboData_warp_type(); break;
34348 case GCDWARPSENS: FFScript::getComboData_warp_sensitive(); break;
34349 case GCDWARPDIRECT: FFScript::getComboData_warp_direct(); break;
34350 case GCDWARPLOCATION: FFScript::getComboData_warp_location(); break;
34351 case GCDWATER: FFScript::getComboData_water(); break;
34352 case GCDWHISTLE: FFScript::getComboData_whistle(); break;
34353 case GCDWINGAME: FFScript::getComboData_win_game(); break;
34354 case GCDBLOCKWEAPLVL: FFScript::getComboData_block_weapon_lvl(); break;
34355 case GCDTILE: FFScript::getComboData_tile(); break;
34356 case GCDFLIP: FFScript::getComboData_flip(); break;
34357 case GCDWALK: FFScript::getComboData_walk(); break;
34358 case GCDTYPE: FFScript::getComboData_type(); break;
34359 case GCDCSETS: FFScript::getComboData_csets(); break;
34360 case GCDFOO: break;
34361 case GCDFRAMES: FFScript::getComboData_frames(); break;
34362 case GCDSPEED: FFScript::getComboData_speed(); break;
34363 case GCDNEXTCOMBO: FFScript::getComboData_nextcombo(); break;
34364 case GCDNEXTCSET: FFScript::getComboData_nextcset(); break;
34365 case GCDFLAG: FFScript::getComboData_flag(); break;
34366 case GCDSKIPANIM: FFScript::getComboData_skipanim(); break;
34367 case GCDNEXTTIMER: FFScript::getComboData_nexttimer(); break;
34368 case GCDSKIPANIMY: FFScript::getComboData_skipanimy(); break;
34369 case GCDANIMFLAGS: FFScript::getComboData_animflags(); break;
34370 case GCDBLOCKWEAPON: FFScript::getComboData_block_weapon(); break;
34371 case GCDEXPANSION: FFScript::getComboData_expansion(); break;
34372 case GCDSTRIKEWEAPONS: FFScript::getComboData_strike_weapons(); break;
34373 case SCDBLOCKENEM: FFScript::setComboData_block_enemies(); break;
34374 case SCDBLOCKHOLE: FFScript::setComboData_block_hole(); break;
34375 case SCDBLOCKTRIG: FFScript::setComboData_block_trigger(); break;
34376 case SCDCONVEYSPDX: FFScript::setComboData_conveyor_x_speed(); break;
34377 case SCDCONVEYSPDY: FFScript::setComboData_conveyor_y_speed(); break;
34378 case SCDCREATEENEM: FFScript::setComboData_create_enemy(); break;
34379 case SCDCREATEENEMWH: FFScript::setComboData_create_enemy_when(); break;
34380 case SCDCREATEENEMCH: FFScript::setComboData_create_enemy_change(); break;
34381 case SCDDIRCHTYPE: FFScript::setComboData_directional_change_type(); break;
34382 case SCDDISTCHTILES: FFScript::setComboData_distance_change_tiles(); break;
34383 case SCDDIVEITEM: FFScript::setComboData_dive_item(); break;
34384 case SCDDOCK: FFScript::setComboData_dock(); break;
34385 case SCDFAIRY: FFScript::setComboData_fairy(); break;
34386 case SCDFFCOMBOATTRIB: FFScript::setComboData_ff_combo_attr_change(); break;
34387 case SCDFOOTDECOTILE: FFScript::setComboData_foot_decorations_tile(); break;
34388 case SCDFOOTDECOTYPE: FFScript::setComboData_foot_decorations_type(); break;
34389 case SCDHOOKSHOTGRAB: FFScript::setComboData_hookshot_grab_point(); break;
34390 case SCDLADDERPASS: FFScript::setComboData_ladder_pass(); break;
34391 case SCDLOCKBLOCKTYPE: FFScript::setComboData_lock_block_type(); break;
34392 case SCDLOCKBLOCKCHANGE: FFScript::setComboData_lock_block_change(); break;
34393 case SCDMAGICMIRRORTYPE: FFScript::setComboData_magic_mirror_type(); break;
34394 case SCDMODIFYHPAMOUNT: FFScript::setComboData_modify_hp_amount(); break;
34395 case SCDMODIFYHPDELAY: FFScript::setComboData_modify_hp_delay(); break;
34396 case SCDMODIFYHPTYPE: FFScript::setComboData_modify_hp_type(); break;
34397 case SCDMODIFYMPAMOUNT: FFScript::setComboData_modify_mp_amount(); break;
34398 case SCDMODIFYMPDELAY: FFScript::setComboData_modify_mp_delay(); break;
34399 case SCDMODIFYMPTYPE: FFScript::setComboData_modify_mp_type(); break;
34400 case SCDNOPUSHBLOCKS: FFScript::setComboData_no_push_blocks(); break;
34401 case SCDOVERHEAD: FFScript::setComboData_overhead(); break;
34402 case SCDPLACEENEMY: FFScript::setComboData_place_enemy(); break;
34403 case SCDPUSHDIR: FFScript::setComboData_push_direction(); break;
34404 case SCDPUSHWEIGHT: FFScript::setComboData_push_weight(); break;
34405 case SCDPUSHWAIT: FFScript::setComboData_push_wait(); break;
34406 case SCDPUSHED: FFScript::setComboData_pushed(); break;
34407 case SCDRAFT: FFScript::setComboData_raft(); break;
34408 case SCDRESETROOM: FFScript::setComboData_reset_room(); break;
34409 case SCDSAVEPOINT: FFScript::setComboData_save_point_type(); break;
34410 case SCDSCREENFREEZE: FFScript::setComboData_screen_freeze_type(); break;
34411 case SCDSECRETCOMBO: FFScript::setComboData_secret_combo(); break;
34412 case SCDSINGULAR: FFScript::setComboData_singular(); break;
34413 case SCDSLOWMOVE: FFScript::setComboData_slow_movement(); break;
34414 case SCDSTATUE: FFScript::setComboData_statue_type(); break;
34415 case SCDSTEPTYPE: FFScript::setComboData_step_type(); break;
34416 case SCDSTEPCHANGETO: FFScript::setComboData_step_change_to(); break;
34417 case SCDSTRIKEREMNANTS: FFScript::setComboData_strike_remnants(); break;
34418 case SCDSTRIKEREMNANTSTYPE: FFScript::setComboData_strike_remnants_type(); break;
34419 case SCDSTRIKECHANGE: FFScript::setComboData_strike_change(); break;
34420 case SCDSTRIKECHANGEITEM: FFScript::setComboData_strike_item(); break;
34421 case SCDTOUCHITEM: FFScript::setComboData_touch_item(); break;
34422 case SCDTOUCHSTAIRS: FFScript::setComboData_touch_stairs(); break;
34423 case SCDTRIGGERTYPE: FFScript::setComboData_trigger_type(); break;
34424 case SCDTRIGGERSENS: FFScript::setComboData_trigger_sensitive(); break;
34425 case SCDWARPTYPE: FFScript::setComboData_warp_type(); break;
34426 case SCDWARPSENS: FFScript::setComboData_warp_sensitive(); break;
34427 case SCDWARPDIRECT: FFScript::setComboData_warp_direct(); break;
34428 case SCDWARPLOCATION: FFScript::setComboData_warp_location(); break;
34429 case SCDWATER: FFScript::setComboData_water(); break;
34430 case SCDWHISTLE: FFScript::setComboData_whistle(); break;
34431 case SCDWINGAME: FFScript::setComboData_win_game(); break;
34432 case SCDBLOCKWEAPLVL: FFScript::setComboData_block_weapon_lvl(); break;
34433 case SCDTILE: FFScript::setComboData_tile(); break;
34434 case SCDFLIP: FFScript::setComboData_flip(); break;
34435 case SCDWALK: FFScript::setComboData_walk(); break;
34436 case SCDTYPE: FFScript::setComboData_type(); break;
34437 case SCDCSETS: FFScript::setComboData_csets(); break;
34438 case SCDFOO: break;
34439 case SCDFRAMES: FFScript::setComboData_frames(); break;
34440 case SCDSPEED: FFScript::setComboData_speed(); break;
34441 case SCDNEXTCOMBO: FFScript::setComboData_nextcombo(); break;
34442 case SCDNEXTCSET: FFScript::setComboData_nextcset(); break;
34443 case SCDFLAG: FFScript::setComboData_flag(); break;
34444 case SCDSKIPANIM: FFScript::setComboData_skipanim(); break;
34445 case SCDNEXTTIMER: FFScript::setComboData_nexttimer(); break;
34446 case SCDSKIPANIMY: FFScript::setComboData_skipanimy(); break;
34447 case SCDANIMFLAGS: FFScript::setComboData_animflags(); break;
34448 case SCDBLOCKWEAPON: FFScript::setComboData_block_weapon(ri->d[rEXP1]); break;
34449 case SCDEXPANSION: FFScript::setComboData_expansion(ri->d[rEXP1]); break;
34450 case SCDSTRIKEWEAPONS: FFScript::setComboData_strike_weapons(ri->d[rEXP1]); break;
34451
34452 //SpriteData
34453
34454 //case GETSPRITEDATASTRING:
34455 case GETSPRITEDATATILE: FFScript::getSpriteDataTile(); break;
34456 case GETSPRITEDATAMISC: FFScript::getSpriteDataCSets(); break;
34457 case GETSPRITEDATACGETS: FFScript::getSpriteDataCSets(); break;
34458 case GETSPRITEDATAFRAMES: FFScript::getSpriteDataFrames(); break;
34459 case GETSPRITEDATASPEED: FFScript::getSpriteDataSpeed(); break;
34460 case GETSPRITEDATATYPE: FFScript::getSpriteDataType(); break;
34461
34462 //case SETSPRITEDATASTRING:
34463 case SETSPRITEDATATILE: FFScript::setSpriteDataTile(); break;
34464 case SETSPRITEDATAMISC: FFScript::setSpriteDataMisc(); break;
34465 case SETSPRITEDATACSETS: FFScript::setSpriteDataCSets(); break;
34466 case SETSPRITEDATAFRAMES: FFScript::setSpriteDataFrames(); break;
34467 case SETSPRITEDATASPEED: FFScript::setSpriteDataSpeed(); break;
34468 case SETSPRITEDATATYPE: FFScript::setSpriteDataType(); break;
34469
34470 //Game over Screen
34471 case SETCONTINUESCREEN: FFScript::FFChangeSubscreenText(); break;
34472 case SETCONTINUESTRING: FFScript::FFSetSaveScreenSetting(); break;
34473
34474 //new npc functions for npc scripts
34475
34476 case NPCDEAD:
34477 FFCore.do_isdeadnpc();
34478 break;
34479
34480 case NPCCANSLIDE:
34481 FFCore.do_canslidenpc();
34482 break;
34483
34484 case NPCSLIDE:
34485 FFCore.do_slidenpc();
34486 break;
34487
34488 case NPCKICKBUCKET:
34489 {
34490 FFScript::deallocateAllArrays(ScriptType::NPC, ri->guyref);
34491 if(type == ScriptType::NPC && ri->guyref == i)
34492 {
34493 FFCore.do_npc_delete();
34494 return RUNSCRIPT_SELFDELETE;
34495 }
34496 FFCore.do_npc_delete();
34497 break;
34498 }
34499 case LWPNDEL:
34500 {
34501 FFScript::deallocateAllArrays(ScriptType::Lwpn, ri->lwpn);
34502 if(type == ScriptType::Lwpn && ri->lwpn == i)
34503 {
34504 FFCore.do_lweapon_delete();
34505 return RUNSCRIPT_SELFDELETE;
34506 }
34507 FFCore.do_lweapon_delete();
34508 break;
34509 }
34510 case EWPNDEL:
34511 {
34512 FFScript::deallocateAllArrays(ScriptType::Ewpn, ri->ewpn);
34513 if(type == ScriptType::Ewpn && ri->ewpn == i)
34514 {
34515 FFCore.do_eweapon_delete();
34516 return RUNSCRIPT_SELFDELETE;
34517 }
34518 FFCore.do_eweapon_delete();
34519 break;
34520 }
34521 case ITEMDEL:
34522 {
34523 8 FFScript::deallocateAllArrays(ScriptType::ItemSprite, ri->itemref);
34524
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
8 if(type == ScriptType::ItemSprite && ri->itemref == i)
34525 {
34526
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(FFCore.do_itemsprite_delete())
34527 8 return RUNSCRIPT_SELFDELETE;
34528 }
34529 else FFCore.do_itemsprite_delete();
34530 break;
34531 }
34532
34533 case NPCSTOPBGSFX:
34534 FFCore.do_npc_stopbgsfx();
34535 break;
34536
34537 case NPCATTACK:
34538 FFCore.do_npcattack();
34539 break;
34540
34541 case NPCNEWDIR:
34542 FFCore.do_npc_newdir();
34543 break;
34544
34545 case NPCCONSTWALK:
34546 FFCore.do_npc_constwalk();
34547 break;
34548
34549
34550
34551 case NPCVARWALK:
34552 FFCore.do_npc_varwalk();
34553 break;
34554
34555 case NPCVARWALK8:
34556 FFCore.do_npc_varwalk8();
34557 break;
34558
34559 case NPCCONSTWALK8:
34560 FFCore.do_npc_constwalk8();
34561 break;
34562
34563 case NPCHALTWALK:
34564 FFCore.do_npc_haltwalk();
34565 break;
34566
34567 case NPCHALTWALK8:
34568 FFCore.do_npc_haltwalk8();
34569 break;
34570
34571 case NPCFLOATWALK:
34572 FFCore.do_npc_floatwalk();
34573 break;
34574
34575 case NPCFIREBREATH:
34576 FFCore.do_npc_breathefire();
34577 break;
34578
34579 case NPCNEWDIR8:
34580 FFCore.do_npc_newdir8();
34581 break;
34582
34583 case NPCLINKINRANGE:
34584 FFCore.do_npc_hero_in_range(false);
34585 break;
34586
34587 case NPCCANMOVE:
34588 FFCore.do_npc_canmove(false);
34589 break;
34590
34591 case NPCHITWITH:
34592 FFCore.do_npc_simulate_hit(false);
34593 break;
34594
34595 case NPCKNOCKBACK:
34596 FFCore.do_npc_knockback(false);
34597 break;
34598
34599 case NPCGETINITDLABEL:
34600 FFCore.get_npcdata_initd_label(false);
34601 break;
34602
34603 case NPCADD:
34604 FFCore.do_npc_add(false);
34605 break;
34606
34607 case NPCMOVEPAUSED:
34608 {
34609 ri->d[rEXP1] = 0;
34610 if(GuyH::loadNPC(ri->guyref, "npc->MovePaused()") == SH::_NoError)
34611 {
34612 ri->d[rEXP1] = GuyH::getNPC()->is_move_paused() ? 10000 : 0;
34613 }
34614 break;
34615 }
34616 case NPCMOVE:
34617 {
34618 int32_t dir = ri->d[rINDEX] / 10000;
34619 zfix px = zslongToFix(ri->d[rEXP2]);
34620 int32_t special = ri->d[rEXP1] / 10000;
34621 ri->d[rEXP1] = 0;
34622 if(GuyH::loadNPC(ri->guyref, "npc->Move()") == SH::_NoError)
34623 {
34624 ri->d[rEXP1] = GuyH::getNPC()->moveDir(dir, px, special) ? 10000 : 0;
34625 }
34626 break;
34627 }
34628 case NPCMOVEANGLE:
34629 {
34630 zfix degrees = zslongToFix(ri->d[rINDEX]);
34631 zfix px = zslongToFix(ri->d[rEXP2]);
34632 int32_t special = ri->d[rEXP1] / 10000;
34633 ri->d[rEXP1] = 0;
34634 if(GuyH::loadNPC(ri->guyref, "npc->MoveAtAngle()") == SH::_NoError)
34635 {
34636 ri->d[rEXP1] = GuyH::getNPC()->moveAtAngle(degrees, px, special) ? 10000 : 0;
34637 }
34638 break;
34639 }
34640 case NPCMOVEXY:
34641 {
34642 zfix dx = zslongToFix(ri->d[rINDEX]);
34643 zfix dy = zslongToFix(ri->d[rEXP2]);
34644 int32_t special = ri->d[rEXP1] / 10000;
34645 ri->d[rEXP1] = 0;
34646 if(GuyH::loadNPC(ri->guyref, "npc->MoveXY()") == SH::_NoError)
34647 {
34648 ri->d[rEXP1] = GuyH::getNPC()->movexy(dx, dy, special) ? 10000 : 00;
34649 }
34650 break;
34651 }
34652 case NPCCANMOVEDIR:
34653 {
34654 int32_t dir = ri->d[rINDEX] / 10000;
34655 zfix px = zslongToFix(ri->d[rEXP2]);
34656 int32_t special = ri->d[rEXP1] / 10000;
34657 ri->d[rEXP1] = 0;
34658 if(GuyH::loadNPC(ri->guyref, "npc->CanMove()") == SH::_NoError)
34659 {
34660 ri->d[rEXP1] = GuyH::getNPC()->can_moveDir(dir, px, special) ? 10000 : 0;
34661 }
34662 break;
34663 }
34664 case NPCCANMOVEANGLE:
34665 {
34666 zfix degrees = zslongToFix(ri->d[rINDEX]);
34667 zfix px = zslongToFix(ri->d[rEXP2]);
34668 int32_t special = ri->d[rEXP1] / 10000;
34669 ri->d[rEXP1] = 0;
34670 if(GuyH::loadNPC(ri->guyref, "npc->CanMoveAtAngle()") == SH::_NoError)
34671 {
34672 ri->d[rEXP1] = GuyH::getNPC()->can_moveAtAngle(degrees, px, special) ? 10000 : 0;
34673 }
34674 break;
34675 }
34676 case NPCCANMOVEXY:
34677 {
34678 zfix dx = zslongToFix(ri->d[rINDEX]);
34679 zfix dy = zslongToFix(ri->d[rEXP2]);
34680 int32_t special = ri->d[rEXP1] / 10000;
34681 ri->d[rEXP1] = 0;
34682 if(GuyH::loadNPC(ri->guyref, "npc->CanMoveXY()") == SH::_NoError)
34683 {
34684 ri->d[rEXP1] = GuyH::getNPC()->can_movexy(dx, dy, special) ? 10000 : 0;
34685 }
34686 break;
34687 }
34688 case NPCCANPLACE:
34689 {
34690 ri->guyref = SH::read_stack(ri->sp + 6);
34691 ri->d[rEXP1] = 0;
34692 if(GuyH::loadNPC(ri->guyref, "npc->CanPlace()") == SH::_NoError)
34693 {
34694 zfix nx = zslongToFix(SH::read_stack(ri->sp + 5));
34695 zfix ny = zslongToFix(SH::read_stack(ri->sp + 4));
34696 int special = SH::read_stack(ri->sp + 3) / 10000;
34697 bool kb = SH::read_stack(ri->sp + 2)!=0;
34698 int nw = SH::read_stack(ri->sp + 1) / 10000;
34699 int nh = SH::read_stack(ri->sp + 0) / 10000;
34700 ri->d[rEXP1] = GuyH::getNPC()->scr_canplace(nx, ny, special, kb, nw, nh) ? 10000 : 0;
34701 }
34702 break;
34703 }
34704
34705 case PLAYENHMUSICEX:
34706 // DEPRECATED
34707 do_enh_music(false);
34708 break;
34709
34710 case GETENHMUSICPOS:
34711 FFCore.do_get_music_position();
34712 break;
34713
34714 case SETENHMUSICPOS:
34715 FFCore.do_set_music_position(false);
34716 break;
34717
34718 case SETENHMUSICSPEED:
34719 FFCore.do_set_music_speed(false);
34720 break;
34721
34722 case GETENHMUSICLEN:
34723 FFCore.do_get_music_length();
34724 break;
34725
34726 case SETENHMUSICLOOP:
34727 FFCore.do_set_music_loop();
34728 break;
34729
34730 case ENHCROSSFADE:
34731 do_enh_music_crossfade();
34732 break;
34733
34734 case DIREXISTS:
34735 FFCore.do_checkdir(true);
34736 break;
34737
34738 case FILEEXISTS:
34739 FFCore.do_checkdir(false);
34740 break;
34741
34742 case FILESYSREMOVE:
34743 FFCore.do_fs_remove();
34744 break;
34745
34746 case TOBYTE:
34747 do_tobyte();
34748 break;
34749 case TOWORD:
34750 do_toword();
34751 break;
34752 case TOSHORT: do_toshort(); break;
34753 case TOSIGNEDBYTE: do_tosignedbyte(); break;
34754 case TOINTEGER: do_tointeger(); break;
34755 case CEILING: do_ceiling(); break;
34756 case FLOOR: do_floor(); break;
34757
34758 case FILECLOSE:
34759 {
34760 FFCore.do_fclose();
34761 break;
34762 }
34763 case FILEFREE:
34764 {
34765 1 FFCore.do_deallocate_file();
34766 1 break;
34767 }
34768 case FILEOWN:
34769 {
34770 1 user_file* f = checkFile(ri->fileref, "Free()", false);
34771
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(f) f->own(type, i);
34772 1 break;
34773 }
34774 case FILEISALLOCATED:
34775 {
34776 FFCore.do_file_isallocated();
34777 break;
34778 }
34779 case FILEISVALID:
34780 {
34781 FFCore.do_file_isvalid();
34782 break;
34783 }
34784 case FILEALLOCATE:
34785 {
34786 FFCore.do_allocate_file();
34787 break;
34788 }
34789 case FILEFLUSH:
34790 {
34791 1 FFCore.do_fflush();
34792 1 break;
34793 }
34794 case FILEREMOVE:
34795 {
34796 FFCore.do_fremove();
34797 break;
34798 }
34799 case FILEGETCHAR:
34800 {
34801 FFCore.do_file_getchar();
34802 break;
34803 }
34804 case FILEREWIND:
34805 {
34806 FFCore.do_file_rewind();
34807 break;
34808 }
34809 case FILECLEARERR:
34810 {
34811 FFCore.do_file_clearerr();
34812 break;
34813 }
34814
34815 case FILEOPEN:
34816 {
34817 1 FFCore.do_fopen(false, "rb+");
34818 1 break;
34819 }
34820 case FILECREATE:
34821 {
34822 1 FFCore.do_fopen(false, "wb+");
34823 1 break;
34824 }
34825 case FILEOPENMODE:
34826 {
34827 int32_t arrayptr = get_register(sarg2) / 10000;
34828 string mode;
34829 ArrayH::getString(arrayptr, mode, 16);
34830 FFCore.do_fopen(false, mode.c_str());
34831 break;
34832 }
34833 case FILEREADSTR:
34834 {
34835 FFCore.do_file_readstring();
34836 break;
34837 }
34838 case FILEWRITESTR:
34839 {
34840 279 FFCore.do_file_writestring();
34841 279 break;
34842 }
34843 case FILEPUTCHAR:
34844 {
34845 FFCore.do_file_putchar();
34846 break;
34847 }
34848 case FILEUNGETCHAR:
34849 {
34850 FFCore.do_file_ungetchar();
34851 break;
34852 }
34853
34854 case FILEREADCHARS:
34855 {
34856 FFCore.do_file_readchars();
34857 break;
34858 }
34859 case FILEREADBYTES:
34860 {
34861 FFCore.do_file_readbytes();
34862 break;
34863 }
34864 case FILEREADINTS:
34865 {
34866 FFCore.do_file_readints();
34867 break;
34868 }
34869 case FILEWRITECHARS:
34870 {
34871 FFCore.do_file_writechars();
34872 break;
34873 }
34874 case FILEWRITEBYTES:
34875 {
34876 FFCore.do_file_writebytes();
34877 break;
34878 }
34879 case FILEWRITEINTS:
34880 {
34881 FFCore.do_file_writeints();
34882 break;
34883 }
34884 case FILESEEK:
34885 {
34886 FFCore.do_file_seek();
34887 break;
34888 }
34889 case FILEGETERROR:
34890 {
34891 FFCore.do_file_geterr();
34892 break;
34893 }
34894 //Directory
34895 case DIRECTORYGET:
34896 {
34897 FFCore.do_directory_get();
34898 break;
34899 }
34900 case DIRECTORYRELOAD:
34901 {
34902 FFCore.do_directory_reload();
34903 break;
34904 }
34905 case DIRECTORYFREE:
34906 {
34907 FFCore.do_directory_free();
34908 break;
34909 }
34910 case DIRECTORYOWN:
34911 {
34912 if(user_dir* dr = checkDir(ri->directoryref, "Own()"))
34913 {
34914 dr->own(type, i);
34915 }
34916 break;
34917 }
34918 //Stack
34919 case STACKFREE:
34920 {
34921 if(user_stack* st = checkStack(ri->stackref, "Free()", true))
34922 {
34923 st->clear();
34924 }
34925 break;
34926 }
34927 case STACKOWN:
34928 {
34929 if(user_stack* st = checkStack(ri->stackref, "Own()"))
34930 {
34931 st->own(type, i);
34932 }
34933 break;
34934 }
34935 case STACKCLEAR:
34936 {
34937 if(user_stack* st = checkStack(ri->stackref, "Clear()"))
34938 {
34939 st->clearStack();
34940 }
34941 break;
34942 }
34943 case STACKGET:
34944 {
34945 if(user_stack* st = checkStack(ri->stackref, "Get()", true))
34946 {
34947 int32_t indx = get_register(sarg1); //NOT /10000
34948 set_register(sarg1, st->get(indx)); //NOT *10000
34949 }
34950 else set_register(sarg1, 0L);
34951 break;
34952 }
34953 case STACKSET:
34954 {
34955 if(user_stack* st = checkStack(ri->stackref, "Set()", true))
34956 {
34957 int32_t indx = get_register(sarg1); //NOT /10000
34958 int32_t val = get_register(sarg2); //NOT /10000
34959 st->set(indx, val); //NOT *10000
34960 }
34961 break;
34962 }
34963 case STACKPOPBACK:
34964 {
34965 if(user_stack* st = checkStack(ri->stackref, "PopBack()", true))
34966 {
34967 set_register(sarg1, st->pop_back()); //NOT *10000
34968 }
34969 else set_register(sarg1, 0L);
34970 break;
34971 }
34972 case STACKPOPFRONT:
34973 {
34974 if(user_stack* st = checkStack(ri->stackref, "PopFront()", true))
34975 {
34976 set_register(sarg1, st->pop_front()); //NOT *10000
34977 }
34978 else set_register(sarg1, 0L);
34979 break;
34980 }
34981 case STACKPEEKBACK:
34982 {
34983 if(user_stack* st = checkStack(ri->stackref, "PeekBack()", true))
34984 {
34985 set_register(sarg1, st->peek_back()); //NOT *10000
34986 }
34987 else set_register(sarg1, 0L);
34988 break;
34989 }
34990 case STACKPEEKFRONT:
34991 {
34992 if(user_stack* st = checkStack(ri->stackref, "PeekFront()", true))
34993 {
34994 set_register(sarg1, st->peek_front()); //NOT *10000
34995 }
34996 else set_register(sarg1, 0L);
34997 break;
34998 }
34999 case STACKPUSHBACK:
35000 {
35001 if(user_stack* st = checkStack(ri->stackref, "PushBack()", true))
35002 {
35003 int32_t val = get_register(sarg1); //NOT /10000
35004 st->push_back(val);
35005 }
35006 break;
35007 }
35008 case STACKPUSHFRONT:
35009 {
35010 if(user_stack* st = checkStack(ri->stackref, "PushFront()", true))
35011 {
35012 int32_t val = get_register(sarg1); //NOT /10000
35013 st->push_front(val);
35014 }
35015 break;
35016 }
35017
35018 //Module
35019 case MODULEGETIC:
35020 {
35021
35022 int32_t buf_pointer = SH::get_arg(sarg1, false) / 10000;
35023 int32_t element = SH::get_arg(sarg2, false) / 10000;
35024
35025 if ( ((unsigned)element) > 511 )
35026 {
35027 Z_scripterrlog("Illegal itemclass supplied to ZInfo->GetItemClass().\nLegal values are 1 to 511.\n");
35028 }
35029 else
35030 {
35031 char buffer[256] = {0};
35032 strcpy(buffer,ZI.getItemClassName(element));
35033 buffer[255] = '\0';
35034 if(ArrayH::setArray(buf_pointer, buffer) == SH::_Overflow)
35035 {
35036 Z_scripterrlog("Dest string supplied to 'Module->GetItemClass()' is not large enough\n");
35037 }
35038 }
35039
35040 break;
35041 }
35042
35043 //{ Randgen Stuff
35044 case RNGRAND1:
35045 if(user_rng* r = checkRNG(ri->rngref, "Rand()"))
35046 {
35047 ri->d[rEXP1] = r->rand(214748, -214748)*10000L;
35048 }
35049 else ri->d[rEXP1] = -10000L;
35050 break;
35051 case RNGRAND2:
35052
1/2
✓ Branch 0 taken 1338 times.
✗ Branch 1 not taken.
1338 if(user_rng* r = checkRNG(ri->rngref, "Rand(int32_t)"))
35053 {
35054 1338 set_register(sarg1,r->rand(get_register(sarg1)/10000L)*10000L);
35055 1338 }
35056 else set_register(sarg1,-10000L);
35057 1338 break;
35058 case RNGRAND3:
35059
1/2
✓ Branch 0 taken 301905 times.
✗ Branch 1 not taken.
301905 if(user_rng* r = checkRNG(ri->rngref, "Rand(int32_t,int32_t)"))
35060 {
35061 301905 set_register(sarg1,r->rand(get_register(sarg1)/10000L, get_register(sarg2)/10000L)* 10000L);
35062 301905 }
35063 else set_register(sarg1,-10000L);
35064 301905 break;
35065 case RNGLRAND1:
35066 if(user_rng* r = checkRNG(ri->rngref, "LRand()"))
35067 {
35068 ri->d[rEXP1] = r->rand();
35069 }
35070 else ri->d[rEXP1] = -10000L;
35071 break;
35072 case RNGLRAND2:
35073 if(user_rng* r = checkRNG(ri->rngref, "LRand(int32_t)"))
35074 {
35075 ri->d[rEXP1] = r->rand(get_register(sarg1));
35076 }
35077 else ri->d[rEXP1] = -10000L;
35078 break;
35079 case RNGLRAND3:
35080 if(user_rng* r = checkRNG(ri->rngref, "LRand(int32_t,int32_t)"))
35081 {
35082 ri->d[rEXP1] = r->rand(get_register(sarg1), get_register(sarg2));
35083 }
35084 else ri->d[rEXP1] = -10000L;
35085 break;
35086 case RNGSEED:
35087
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73 times.
73 if(user_rng* r = checkRNG(ri->rngref, "SRand(int32_t)"))
35088 {
35089 73 r->srand(get_register(sarg1));
35090 73 }
35091 73 break;
35092 case RNGRSEED:
35093 if(user_rng* r = checkRNG(ri->rngref, "SRand()"))
35094 {
35095 ri->d[rEXP1] = r->srand();
35096 }
35097 else ri->d[rEXP1] = -10000;
35098 break;
35099 case RNGFREE:
35100
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(user_rng* r = checkRNG(ri->rngref, "Free()", true))
35101 {
35102 6 r->clear();
35103 6 }
35104 6 break;
35105 case RNGOWN:
35106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(user_rng* r = checkRNG(ri->rngref, "Own()", false))
35107 {
35108 8 r->own(type, i);
35109 8 }
35110 8 break;
35111 //}
35112 case LOADGENERICDATA:
35113 68 FFCore.do_loadgenericdata(false); break;
35114 case RUNGENFRZSCR:
35115 {
35116 10 bool r = FFCore.runGenericFrozenEngine(word(ri->genericdataref));
35117 10 set_register(sarg1, r ? 10000L : 0L);
35118 10 break;
35119 }
35120
35121 default:
35122 {
35123 Z_scripterrlog("Invalid ZASM command %lu reached; terminating\n", scommand);
35124 hit_invalid_zasm = true;
35125 scommand = 0xFFFF;
35126 break;
35127 }
35128 }
35129
1/2
✓ Branch 0 taken 705629386 times.
✗ Branch 1 not taken.
705629386 if(earlyretval == RUNSCRIPT_SELFDELETE)
35130 {
35131 earlyretval = -1;
35132 return RUNSCRIPT_SELFDELETE;
35133 }
35134
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 705629386 times.
705629386 if(hit_invalid_zasm) break;
35135
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 705629386 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
705629386 if(script_funcrun && ri->pc == MAX_PC)
35136 return RUNSCRIPT_OK;
35137
35138 #ifdef _SCRIPT_COUNTER
35139 end_time = std::chrono::steady_clock::now();
35140 script_timer[scommand] += std::chrono::duration_cast<std::chrono::nanoseconds>(end_time - start_time).count();
35141 script_execount[scommand] += 1;
35142 #endif
35143
35144
2/2
✓ Branch 0 taken 705567423 times.
✓ Branch 1 taken 61963 times.
705629386 if (type == ScriptType::Combo)
35145 {
35146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61963 times.
61963 if(combopos_modified == i)
35147 {
35148 //Combo changed! Abort script!
35149 return RUNSCRIPT_OK;
35150 }
35151 61963 }
35152
1/2
✓ Branch 0 taken 705629386 times.
✗ Branch 1 not taken.
705629386 if(increment) ri->pc++;
35153 else increment = true;
35154
1/2
✓ Branch 0 taken 705629386 times.
✗ Branch 1 not taken.
705629386 if ( ri->pc == MAX_PC ) //rolled over from overflow?
35155 {
35156 Z_scripterrlog("Script PC overflow! Too many ZASM lines?\n");
35157 ri->pc = 0;
35158 scommand = 0xFFFF;
35159 }
35160
35161
1/2
✓ Branch 0 taken 705629386 times.
✗ Branch 1 not taken.
705629386 if(earlyretval > -1) //Should this be below the 'commands_run += 1'? Unsure. -Em
35162 {
35163 auto v = earlyretval;
35164 earlyretval = -1;
35165 return earlyretval;
35166 }
35167
35168 // If running a JIT compiled script, we're only here to do a few commands.
35169 705629386 commands_run += 1;
35170
3/4
✓ Branch 0 taken 705629386 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3089172 times.
✓ Branch 3 taken 702540214 times.
705629386 if (is_jitted && commands_run == jitted_uncompiled_command_count) break;
35171 }
35172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 712125958 times.
712125958 if(script_funcrun) return RUNSCRIPT_OK;
35173
35174
2/2
✓ Branch 0 taken 712125947 times.
✓ Branch 1 taken 11 times.
712125958 if(!scriptCanSave)
35175 11 scriptCanSave=true;
35176
35177
2/2
✓ Branch 0 taken 710263136 times.
✓ Branch 1 taken 1862822 times.
712125958 if(scommand == WAITDRAW)
35178 {
35179
3/9
✓ Branch 0 taken 1850154 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 188 times.
✓ Branch 6 taken 12480 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
1862822 switch(type)
35180 {
35181 case ScriptType::Global:
35182 case ScriptType::Player:
35183 case ScriptType::DMap:
35184 case ScriptType::OnMap:
35185 case ScriptType::PassiveSubscreen:
35186 case ScriptType::ActiveSubscreen:
35187 case ScriptType::Screen:
35188 case ScriptType::Combo:
35189 1850154 FFCore.waitdraw(type, i) = true;
35190 1850154 break;
35191
35192 case ScriptType::Item:
35193 {
35194 if (!get_qr(qr_NOITEMWAITDRAW))
35195 {
35196 FFCore.waitdraw(ScriptType::Item, i) = true;
35197 }
35198 break;
35199 }
35200
35201 case ScriptType::NPC:
35202 {
35203 //enemy *wp = (enemy*)guys.spr(i);
35204 //wp->waitdraw = 1;
35205 guys.spr(GuyH::getNPCIndex(i))->waitdraw = 1;
35206 break;
35207 }
35208 case ScriptType::Lwpn:
35209 {
35210 188 Lwpns.spr(LwpnH::getLWeaponIndex(i))->waitdraw = 1;
35211 188 break;
35212 }
35213
35214 case ScriptType::Ewpn:
35215 {
35216 12480 Ewpns.spr(EwpnH::getEWeaponIndex(i))->waitdraw = 1;
35217 12480 break;
35218 }
35219 case ScriptType::ItemSprite:
35220 {
35221 items.spr(ItemH::getItemIndex(i))->waitdraw = 1;
35222 break;
35223 }
35224
35225 case ScriptType::FFC:
35226 {
35227 if ( !(get_qr(qr_NOFFCWAITDRAW)) )
35228 {
35229 FFCore.waitdraw(ScriptType::FFC, i) = true;
35230 }
35231 else
35232 {
35233 Z_scripterrlog("Waitdraw cannot be used in script type: %s\n", "ffc, with Script Rule 'No FFC Waitdraw() enabled!");
35234 }
35235 break;
35236 }
35237
35238 case ScriptType::Generic:
35239 case ScriptType::GenericFrozen:
35240 //No Waitdraw
35241 break;
35242
35243 default:
35244 Z_scripterrlog("Waitdraw cannot be used in script type: %s\n", ScriptTypeToString(type));
35245 break;
35246 }
35247 1862822 }
35248
35249
2/2
✓ Branch 0 taken 70466 times.
✓ Branch 1 taken 712055492 times.
712125958 if(scommand == 0xFFFF) //Quit/command list end reached/bad command
35250 {
35251
8/11
✓ Branch 0 taken 1249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6683 times.
✓ Branch 3 taken 18 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10 times.
✓ Branch 6 taken 1009 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60621 times.
✓ Branch 9 taken 836 times.
✓ Branch 10 taken 40 times.
70466 switch(type)
35252 {
35253 case ScriptType::FFC:
35254 {
35255 6683 tmpscr->ffcs[i].script = 0;
35256 6683 auto& data = get_script_engine_data(type, i);
35257 6683 data.doscript = false;
35258 }
35259 6683 break;
35260
35261 case ScriptType::Screen:
35262 18 tmpscr->script = 0;
35263 case ScriptType::Global:
35264 case ScriptType::Player:
35265 case ScriptType::DMap:
35266 case ScriptType::OnMap:
35267 case ScriptType::ActiveSubscreen:
35268 case ScriptType::PassiveSubscreen:
35269 case ScriptType::Combo:
35270 {
35271 1267 auto& data = get_script_engine_data(type, i);
35272 1267 data.doscript = false;
35273 }
35274 1267 break;
35275
35276 case ScriptType::Generic:
35277 user_scripts[script].quit();
35278 break;
35279
35280 case ScriptType::GenericFrozen:
35281 10 gen_active_doscript = 0;
35282 10 break;
35283
35284 case ScriptType::Item:
35285 {
35286
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 815 times.
1009 bool collect = ( ( i < 1 ) || (i == COLLECT_SCRIPT_ITEM_ZERO) );
35287
3/4
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 815 times.
✓ Branch 2 taken 194 times.
✗ Branch 3 not taken.
1009 int new_i = ( collect ) ? (( i != COLLECT_SCRIPT_ITEM_ZERO ) ? (i * -1) : 0) : i;
35288 1009 auto& data = get_script_engine_data(ScriptType::Item, i);
35289
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 815 times.
1009 if ( !collect )
35290 {
35291
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 815 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
815 if ( (itemsbuf[i].flags&ITEM_PASSIVESCRIPT) && game->item[i] ) itemsbuf[i].script = 0; //Quit perpetual scripts, too.
35292 815 data.doscript = 0;
35293 815 data.ref.Clear();
35294 815 }
35295 else
35296 {
35297 194 data.doscript = 0;
35298 194 data.ref.Clear();
35299 }
35300 1009 data.initialized = false;
35301 1009 break;
35302 }
35303 case ScriptType::NPC:
35304 {
35305 guys.spr(GuyH::getNPCIndex(i))->doscript = 0;
35306 guys.spr(GuyH::getNPCIndex(i))->weaponscript = 0;
35307 guys.spr(GuyH::getNPCIndex(i))->initialised = 0;
35308 break;
35309 }
35310 case ScriptType::Lwpn:
35311 {
35312 60621 Lwpns.spr(LwpnH::getLWeaponIndex(i))->doscript = 0;
35313 60621 Lwpns.spr(LwpnH::getLWeaponIndex(i))->weaponscript = 0;
35314 60621 Lwpns.spr(LwpnH::getLWeaponIndex(i))->initialised = 0;
35315 60621 break;
35316 }
35317 case ScriptType::Ewpn:
35318 {
35319
35320 836 Ewpns.spr(EwpnH::getEWeaponIndex(i))->doscript = 0;
35321 836 Ewpns.spr(EwpnH::getEWeaponIndex(i))->weaponscript = 0;
35322 836 Ewpns.spr(EwpnH::getEWeaponIndex(i))->initialised = 0;
35323 836 break;
35324 }
35325 case ScriptType::ItemSprite:
35326 {
35327 40 items.spr(ItemH::getItemIndex(i))->doscript = 0;
35328 40 items.spr(ItemH::getItemIndex(i))->script = 0;
35329 40 items.spr(ItemH::getItemIndex(i))->initialised = 0;
35330 40 break;
35331 }
35332 }
35333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70466 times.
70466 if(!no_dealloc)
35334
3/3
✓ Branch 0 taken 69439 times.
✓ Branch 1 taken 1009 times.
✓ Branch 2 taken 18 times.
70466 switch(type)
35335 {
35336 case ScriptType::Item:
35337 {
35338
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 815 times.
1009 bool collect = ( ( i < 1 ) || (i == COLLECT_SCRIPT_ITEM_ZERO) );
35339
3/4
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 815 times.
✓ Branch 2 taken 194 times.
✗ Branch 3 not taken.
1009 int new_i = ( collect ) ? (( i != COLLECT_SCRIPT_ITEM_ZERO ) ? (i * -1) : 0) : i;
35340 1009 FFScript::deallocateAllArrays(ScriptType::Item, new_i);
35341 1009 break;
35342 }
35343
35344 case ScriptType::Screen:
35345 {
35346 18 FFScript::deallocateAllArrays(ScriptType::Screen, 0);
35347 18 break;
35348 }
35349
35350 default:
35351 69439 FFScript::deallocateAllArrays(type, i);
35352 69439 break;
35353 70466 }
35354
35355 70466 return RUNSCRIPT_STOPPED;
35356 }
35357 else
35358 712055492 ri->pc++;
35359
35360 712055492 return RUNSCRIPT_OK;
35361 712125966 }
35362
35363 script_data* load_scrdata(ScriptType type, word script, int32_t i)
35364 {
35365 switch(type)
35366 {
35367 case ScriptType::FFC:
35368 return ffscripts[script];
35369 case ScriptType::NPC:
35370 return guyscripts[guys.spr(GuyH::getNPCIndex(i))->script];
35371 case ScriptType::Lwpn:
35372 return lwpnscripts[Lwpns.spr(LwpnH::getLWeaponIndex(i))->weaponscript];
35373 case ScriptType::Ewpn:
35374 return ewpnscripts[Ewpns.spr(EwpnH::getEWeaponIndex(i))->weaponscript];
35375 case ScriptType::ItemSprite:
35376 return itemspritescripts[items.spr(ItemH::getItemIndex(i))->script];
35377 case ScriptType::Item:
35378 return itemscripts[script];
35379 case ScriptType::Global:
35380 return globalscripts[script];
35381 case ScriptType::Generic:
35382 case ScriptType::GenericFrozen:
35383 return genericscripts[script];
35384 case ScriptType::Player:
35385 return playerscripts[script];
35386 case ScriptType::DMap:
35387 return dmapscripts[script];
35388 case ScriptType::OnMap:
35389 case ScriptType::ActiveSubscreen:
35390 case ScriptType::PassiveSubscreen:
35391 return dmapscripts[script];
35392 case ScriptType::Screen:
35393 return screenscripts[script];
35394 case ScriptType::Combo:
35395 return comboscripts[script];
35396 }
35397 return nullptr;
35398 }
35399
35400 //This keeps ffc scripts running beyond the first frame.
35401 7297748 int32_t ffscript_engine(const bool preload)
35402 {
35403
2/2
✓ Branch 0 taken 7282208 times.
✓ Branch 1 taken 15540 times.
7297748 if(preload)
35404 {
35405 15540 throwGenScriptEvent(GENSCR_EVENT_FFC_PRELOAD);
35406 15540 }
35407
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7297748 times.
7297748 if (!FFCore.system_suspend[susptFFCSCRIPTS])
35408 {
35409 //run screen script, first
35410 //zprint("Screen Script Preload? %s \n", ( tmpscr->preloadscript ? "true" : "false"));
35411
4/4
✓ Branch 0 taken 15540 times.
✓ Branch 1 taken 7282208 times.
✓ Branch 2 taken 15527 times.
✓ Branch 3 taken 7266681 times.
7297748 if(( preload && tmpscr->preloadscript) || !preload )
35412 {
35413
2/2
✓ Branch 0 taken 6969052 times.
✓ Branch 1 taken 313169 times.
7282221 if ( FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
35414 {
35415
3/4
✓ Branch 0 taken 9269 times.
✓ Branch 1 taken 303900 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9269 times.
313169 if ( tmpscr->script > 0 && FFCore.doscript(ScriptType::Screen) )
35416 {
35417 9269 ZScriptVersion::RunScript(ScriptType::Screen, tmpscr->script);
35418 9269 }
35419 313169 }
35420 7282221 }
35421 7297748 word c = tmpscr->numFFC();
35422
2/2
✓ Branch 0 taken 229215510 times.
✓ Branch 1 taken 7297748 times.
236513258 for(word i = 0; i < c; i++)
35423 {
35424
2/2
✓ Branch 0 taken 4716025 times.
✓ Branch 1 taken 224499485 times.
229215510 if(tmpscr->ffcs[i].script == 0)
35425 224499485 continue;
35426
35427
4/4
✓ Branch 0 taken 6098 times.
✓ Branch 1 taken 4709927 times.
✓ Branch 2 taken 1703 times.
✓ Branch 3 taken 4395 times.
4716025 if(preload && !(tmpscr->ffcs[i].flags&ffPRELOAD))
35428 4395 continue;
35429
35430
4/4
✓ Branch 0 taken 4707071 times.
✓ Branch 1 taken 4559 times.
✓ Branch 2 taken 4675771 times.
✓ Branch 3 taken 31300 times.
4711630 if((tmpscr->ffcs[i].flags&ffIGNOREHOLDUP)==0 && Hero.getHoldClk()>0)
35431 31300 continue;
35432
35433 4680330 ZScriptVersion::RunScript(ScriptType::FFC, tmpscr->ffcs[i].script, i);
35434 4680330 }
35435 7297748 }
35436
35437
35438 7297748 return 0;
35439 }
35440
35441
35442
35443 ///----------------------------------------------------------------------------------------------------
35444
35445 224 void FFScript::user_files_init()
35446 {
35447
2/2
✓ Branch 0 taken 57344 times.
✓ Branch 1 taken 224 times.
57568 for(int32_t q = 0; q < MAX_USER_FILES; ++q)
35448 {
35449 57344 script_files[q].clear();
35450 57344 }
35451 224 }
35452
35453 224 void FFScript::user_dirs_init()
35454 {
35455
2/2
✓ Branch 0 taken 57344 times.
✓ Branch 1 taken 224 times.
57568 for(int32_t q = 0; q < MAX_USER_DIRS; ++q)
35456 {
35457 57344 script_dirs[q].clear();
35458 57344 }
35459 224 }
35460 344 void FFScript::user_objects_init()
35461 {
35462
2/2
✓ Branch 0 taken 73873312 times.
✓ Branch 1 taken 344 times.
73873656 for(int32_t q = 0; q < MAX_USER_OBJECTS; ++q)
35463 {
35464 73873312 script_objects[q].clear(false);
35465 73873312 }
35466 344 max_valid_object = 0;
35467 344 }
35468
35469 224 void FFScript::user_stacks_init()
35470 {
35471
2/2
✓ Branch 0 taken 57344 times.
✓ Branch 1 taken 224 times.
57568 for(int32_t q = 0; q < MAX_USER_STACKS; ++q)
35472 {
35473 57344 script_stacks[q].clear();
35474 57344 }
35475 224 }
35476
35477 407 void FFScript::user_rng_init()
35478 {
35479
2/2
✓ Branch 0 taken 104192 times.
✓ Branch 1 taken 407 times.
104599 for(int32_t q = 0; q < MAX_USER_RNGS; ++q)
35480 {
35481 104192 replay_register_rng(&script_rnggens[q]);
35482 104192 script_rngs[q].clear();
35483 104192 script_rngs[q].set_gen(&script_rnggens[q]);
35484 104192 }
35485 407 }
35486
35487 void FFScript::user_paldata_init()
35488 {
35489 for (int32_t q = 0; q < MAX_USER_STACKS; ++q)
35490 {
35491 script_paldatas[q].clear();
35492 }
35493 }
35494
35495 2 int32_t FFScript::get_free_file(bool skipError)
35496 {
35497
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 for(int32_t q = 0; q < MAX_USER_FILES; ++q)
35498 {
35499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(!script_files[q].reserved)
35500 {
35501 2 script_files[q].reserved = true;
35502 2 return q+1; //1-indexed; 0 is null value
35503 }
35504 }
35505 if(!skipError) Z_scripterrlog("get_free_file() could not find a valid free file pointer!\n");
35506 return 0;
35507 2 }
35508
35509 int32_t FFScript::get_free_object(bool skipError)
35510 {
35511 for(int32_t q = 0; q < MAX_USER_OBJECTS; ++q)
35512 {
35513 if(!script_objects[q].reserved)
35514 {
35515 script_objects[q].reserved = true;
35516 if(q >= max_valid_object)
35517 max_valid_object = q+1;
35518 return q+1; //1-indexed; 0 is null value
35519 }
35520 }
35521 if(!skipError) Z_scripterrlog("get_free_object() could not find a valid free object pointer!\n");
35522 return 0;
35523 }
35524
35525 int32_t FFScript::get_free_directory(bool skipError)
35526 {
35527 for(int32_t q = 0; q < MAX_USER_DIRS; ++q)
35528 {
35529 if(!script_dirs[q].reserved)
35530 {
35531 script_dirs[q].reserved = true;
35532 return q+1; //1-indexed; 0 is null value
35533 }
35534 }
35535 if(!skipError) Z_scripterrlog("get_free_directory() could not find a valid free directory pointer!\n");
35536 return 0;
35537 }
35538
35539 22 int32_t FFScript::get_free_rng(bool skipError)
35540 {
35541
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 for(int32_t q = 0; q < MAX_USER_RNGS; ++q)
35542 {
35543
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 22 times.
31 if(!script_rngs[q].reserved)
35544 {
35545 22 script_rngs[q].reserved = true;
35546 22 return q+1; //1-indexed; 0 is null value
35547 }
35548 9 }
35549 if(!skipError) Z_scripterrlog("get_free_rng() could not find a valid free rng pointer!\n");
35550 return 0;
35551 22 }
35552
35553 int32_t FFScript::get_free_paldata(bool skipError)
35554 {
35555 for (int32_t q = 0; q < MAX_USER_PALDATAS; ++q)
35556 {
35557 if (!script_paldatas[q].reserved)
35558 {
35559 script_paldatas[q].reserved = true;
35560 return q+1; //1-indexed; 0 is null value
35561 }
35562 }
35563 if (!skipError) Z_scripterrlog("get_free_paldata() could not find a valid free paldata pointer!\n");
35564 return 0;
35565 }
35566
35567 int32_t FFScript::get_free_stack(bool skipError)
35568 {
35569 for(int32_t q = 0; q < MAX_USER_STACKS; ++q)
35570 {
35571 if(!script_stacks[q].reserved)
35572 {
35573 script_stacks[q].reserved = true;
35574 return q+1; //1-indexed; 0 is null value
35575 }
35576 }
35577 if(!skipError) Z_scripterrlog("get_free_stack() could not find a valid free stack pointer!\n");
35578 return 0;
35579 }
35580
35581 // Gotten from 'https://fileinfo.com/filetypes/executable'
35582
187/376
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 115 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 115 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 115 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 115 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 115 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 115 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 115 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 115 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 115 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 115 times.
✗ Branch 23 not taken.
✓ Branch 24 taken 115 times.
✗ Branch 25 not taken.
✓ Branch 26 taken 115 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 115 times.
✗ Branch 29 not taken.
✓ Branch 30 taken 115 times.
✗ Branch 31 not taken.
✓ Branch 32 taken 115 times.
✗ Branch 33 not taken.
✓ Branch 34 taken 115 times.
✗ Branch 35 not taken.
✓ Branch 36 taken 115 times.
✗ Branch 37 not taken.
✓ Branch 38 taken 115 times.
✗ Branch 39 not taken.
✓ Branch 40 taken 115 times.
✗ Branch 41 not taken.
✓ Branch 42 taken 115 times.
✗ Branch 43 not taken.
✓ Branch 44 taken 115 times.
✗ Branch 45 not taken.
✓ Branch 46 taken 115 times.
✗ Branch 47 not taken.
✓ Branch 48 taken 115 times.
✗ Branch 49 not taken.
✓ Branch 50 taken 115 times.
✗ Branch 51 not taken.
✓ Branch 52 taken 115 times.
✗ Branch 53 not taken.
✓ Branch 54 taken 115 times.
✗ Branch 55 not taken.
✓ Branch 56 taken 115 times.
✗ Branch 57 not taken.
✓ Branch 58 taken 115 times.
✗ Branch 59 not taken.
✓ Branch 60 taken 115 times.
✗ Branch 61 not taken.
✓ Branch 62 taken 115 times.
✗ Branch 63 not taken.
✓ Branch 64 taken 115 times.
✗ Branch 65 not taken.
✓ Branch 66 taken 115 times.
✗ Branch 67 not taken.
✓ Branch 68 taken 115 times.
✗ Branch 69 not taken.
✓ Branch 70 taken 115 times.
✗ Branch 71 not taken.
✓ Branch 72 taken 115 times.
✗ Branch 73 not taken.
✓ Branch 74 taken 115 times.
✗ Branch 75 not taken.
✓ Branch 76 taken 115 times.
✗ Branch 77 not taken.
✓ Branch 78 taken 115 times.
✗ Branch 79 not taken.
✓ Branch 80 taken 115 times.
✗ Branch 81 not taken.
✓ Branch 82 taken 115 times.
✗ Branch 83 not taken.
✓ Branch 84 taken 115 times.
✗ Branch 85 not taken.
✓ Branch 86 taken 115 times.
✗ Branch 87 not taken.
✓ Branch 88 taken 115 times.
✗ Branch 89 not taken.
✓ Branch 90 taken 115 times.
✗ Branch 91 not taken.
✓ Branch 92 taken 115 times.
✗ Branch 93 not taken.
✓ Branch 94 taken 115 times.
✗ Branch 95 not taken.
✓ Branch 96 taken 115 times.
✗ Branch 97 not taken.
✓ Branch 98 taken 115 times.
✗ Branch 99 not taken.
✓ Branch 100 taken 115 times.
✗ Branch 101 not taken.
✓ Branch 102 taken 115 times.
✗ Branch 103 not taken.
✓ Branch 104 taken 115 times.
✗ Branch 105 not taken.
✓ Branch 106 taken 115 times.
✗ Branch 107 not taken.
✓ Branch 108 taken 115 times.
✗ Branch 109 not taken.
✓ Branch 110 taken 115 times.
✗ Branch 111 not taken.
✓ Branch 112 taken 115 times.
✗ Branch 113 not taken.
✓ Branch 114 taken 115 times.
✗ Branch 115 not taken.
✓ Branch 116 taken 115 times.
✗ Branch 117 not taken.
✓ Branch 118 taken 115 times.
✗ Branch 119 not taken.
✓ Branch 120 taken 115 times.
✗ Branch 121 not taken.
✓ Branch 122 taken 115 times.
✗ Branch 123 not taken.
✓ Branch 124 taken 115 times.
✗ Branch 125 not taken.
✓ Branch 126 taken 115 times.
✗ Branch 127 not taken.
✓ Branch 128 taken 115 times.
✗ Branch 129 not taken.
✓ Branch 130 taken 115 times.
✗ Branch 131 not taken.
✓ Branch 132 taken 115 times.
✗ Branch 133 not taken.
✓ Branch 134 taken 115 times.
✗ Branch 135 not taken.
✓ Branch 136 taken 115 times.
✗ Branch 137 not taken.
✓ Branch 138 taken 115 times.
✗ Branch 139 not taken.
✓ Branch 140 taken 115 times.
✗ Branch 141 not taken.
✓ Branch 142 taken 115 times.
✗ Branch 143 not taken.
✓ Branch 144 taken 115 times.
✗ Branch 145 not taken.
✓ Branch 146 taken 115 times.
✗ Branch 147 not taken.
✓ Branch 148 taken 115 times.
✗ Branch 149 not taken.
✓ Branch 150 taken 115 times.
✗ Branch 151 not taken.
✓ Branch 152 taken 115 times.
✗ Branch 153 not taken.
✓ Branch 154 taken 115 times.
✗ Branch 155 not taken.
✓ Branch 156 taken 115 times.
✗ Branch 157 not taken.
✓ Branch 158 taken 115 times.
✗ Branch 159 not taken.
✓ Branch 160 taken 115 times.
✗ Branch 161 not taken.
✓ Branch 162 taken 115 times.
✗ Branch 163 not taken.
✓ Branch 164 taken 115 times.
✗ Branch 165 not taken.
✓ Branch 166 taken 115 times.
✗ Branch 167 not taken.
✓ Branch 168 taken 115 times.
✗ Branch 169 not taken.
✓ Branch 170 taken 115 times.
✗ Branch 171 not taken.
✓ Branch 172 taken 115 times.
✗ Branch 173 not taken.
✓ Branch 174 taken 115 times.
✗ Branch 175 not taken.
✓ Branch 176 taken 115 times.
✗ Branch 177 not taken.
✓ Branch 178 taken 115 times.
✗ Branch 179 not taken.
✓ Branch 180 taken 115 times.
✗ Branch 181 not taken.
✓ Branch 182 taken 115 times.
✗ Branch 183 not taken.
✓ Branch 184 taken 115 times.
✗ Branch 185 not taken.
✓ Branch 186 taken 115 times.
✗ Branch 187 not taken.
✓ Branch 188 taken 115 times.
✗ Branch 189 not taken.
✓ Branch 190 taken 115 times.
✗ Branch 191 not taken.
✓ Branch 192 taken 115 times.
✗ Branch 193 not taken.
✓ Branch 194 taken 115 times.
✗ Branch 195 not taken.
✓ Branch 196 taken 115 times.
✗ Branch 197 not taken.
✓ Branch 198 taken 115 times.
✗ Branch 199 not taken.
✓ Branch 200 taken 115 times.
✗ Branch 201 not taken.
✓ Branch 202 taken 115 times.
✗ Branch 203 not taken.
✓ Branch 204 taken 115 times.
✗ Branch 205 not taken.
✓ Branch 206 taken 115 times.
✗ Branch 207 not taken.
✓ Branch 208 taken 115 times.
✗ Branch 209 not taken.
✓ Branch 210 taken 115 times.
✗ Branch 211 not taken.
✓ Branch 212 taken 115 times.
✗ Branch 213 not taken.
✓ Branch 214 taken 115 times.
✗ Branch 215 not taken.
✓ Branch 216 taken 115 times.
✗ Branch 217 not taken.
✓ Branch 218 taken 115 times.
✗ Branch 219 not taken.
✓ Branch 220 taken 115 times.
✗ Branch 221 not taken.
✓ Branch 222 taken 115 times.
✗ Branch 223 not taken.
✓ Branch 224 taken 115 times.
✗ Branch 225 not taken.
✓ Branch 226 taken 115 times.
✗ Branch 227 not taken.
✓ Branch 228 taken 115 times.
✗ Branch 229 not taken.
✓ Branch 230 taken 115 times.
✗ Branch 231 not taken.
✓ Branch 232 taken 115 times.
✗ Branch 233 not taken.
✓ Branch 234 taken 115 times.
✗ Branch 235 not taken.
✓ Branch 236 taken 115 times.
✗ Branch 237 not taken.
✓ Branch 238 taken 115 times.
✗ Branch 239 not taken.
✓ Branch 240 taken 115 times.
✗ Branch 241 not taken.
✓ Branch 242 taken 115 times.
✗ Branch 243 not taken.
✓ Branch 244 taken 115 times.
✗ Branch 245 not taken.
✓ Branch 246 taken 115 times.
✗ Branch 247 not taken.
✓ Branch 248 taken 115 times.
✗ Branch 249 not taken.
✓ Branch 250 taken 115 times.
✗ Branch 251 not taken.
✓ Branch 252 taken 115 times.
✗ Branch 253 not taken.
✓ Branch 254 taken 115 times.
✗ Branch 255 not taken.
✓ Branch 256 taken 115 times.
✗ Branch 257 not taken.
✓ Branch 258 taken 115 times.
✗ Branch 259 not taken.
✓ Branch 260 taken 115 times.
✗ Branch 261 not taken.
✓ Branch 262 taken 115 times.
✗ Branch 263 not taken.
✓ Branch 264 taken 115 times.
✗ Branch 265 not taken.
✓ Branch 266 taken 115 times.
✗ Branch 267 not taken.
✓ Branch 268 taken 115 times.
✗ Branch 269 not taken.
✓ Branch 270 taken 115 times.
✗ Branch 271 not taken.
✓ Branch 272 taken 115 times.
✗ Branch 273 not taken.
✓ Branch 274 taken 115 times.
✗ Branch 275 not taken.
✓ Branch 276 taken 115 times.
✗ Branch 277 not taken.
✓ Branch 278 taken 115 times.
✗ Branch 279 not taken.
✓ Branch 280 taken 115 times.
✗ Branch 281 not taken.
✓ Branch 282 taken 115 times.
✗ Branch 283 not taken.
✓ Branch 284 taken 115 times.
✗ Branch 285 not taken.
✓ Branch 286 taken 115 times.
✗ Branch 287 not taken.
✓ Branch 288 taken 115 times.
✗ Branch 289 not taken.
✓ Branch 290 taken 115 times.
✗ Branch 291 not taken.
✓ Branch 292 taken 115 times.
✗ Branch 293 not taken.
✓ Branch 294 taken 115 times.
✗ Branch 295 not taken.
✓ Branch 296 taken 115 times.
✗ Branch 297 not taken.
✓ Branch 298 taken 115 times.
✗ Branch 299 not taken.
✓ Branch 300 taken 115 times.
✗ Branch 301 not taken.
✓ Branch 302 taken 115 times.
✗ Branch 303 not taken.
✓ Branch 304 taken 115 times.
✗ Branch 305 not taken.
✓ Branch 306 taken 115 times.
✗ Branch 307 not taken.
✓ Branch 308 taken 115 times.
✗ Branch 309 not taken.
✓ Branch 310 taken 115 times.
✗ Branch 311 not taken.
✓ Branch 312 taken 115 times.
✗ Branch 313 not taken.
✓ Branch 314 taken 115 times.
✗ Branch 315 not taken.
✓ Branch 316 taken 115 times.
✗ Branch 317 not taken.
✓ Branch 318 taken 115 times.
✗ Branch 319 not taken.
✓ Branch 320 taken 115 times.
✗ Branch 321 not taken.
✓ Branch 322 taken 115 times.
✗ Branch 323 not taken.
✓ Branch 324 taken 115 times.
✗ Branch 325 not taken.
✓ Branch 326 taken 115 times.
✗ Branch 327 not taken.
✓ Branch 328 taken 115 times.
✗ Branch 329 not taken.
✓ Branch 330 taken 115 times.
✗ Branch 331 not taken.
✓ Branch 332 taken 115 times.
✗ Branch 333 not taken.
✓ Branch 334 taken 115 times.
✗ Branch 335 not taken.
✓ Branch 336 taken 115 times.
✗ Branch 337 not taken.
✓ Branch 338 taken 115 times.
✗ Branch 339 not taken.
✓ Branch 340 taken 115 times.
✗ Branch 341 not taken.
✓ Branch 342 taken 115 times.
✗ Branch 343 not taken.
✓ Branch 344 taken 115 times.
✗ Branch 345 not taken.
✓ Branch 346 taken 115 times.
✗ Branch 347 not taken.
✓ Branch 348 taken 115 times.
✗ Branch 349 not taken.
✓ Branch 350 taken 115 times.
✗ Branch 351 not taken.
✓ Branch 352 taken 115 times.
✗ Branch 353 not taken.
✓ Branch 354 taken 115 times.
✗ Branch 355 not taken.
✓ Branch 356 taken 115 times.
✗ Branch 357 not taken.
✓ Branch 358 taken 115 times.
✗ Branch 359 not taken.
✓ Branch 360 taken 115 times.
✗ Branch 361 not taken.
✓ Branch 362 taken 115 times.
✗ Branch 363 not taken.
✓ Branch 364 taken 115 times.
✗ Branch 365 not taken.
✓ Branch 366 taken 115 times.
✗ Branch 367 not taken.
✓ Branch 368 taken 115 times.
✗ Branch 369 not taken.
✓ Branch 370 taken 115 times.
✗ Branch 371 not taken.
✓ Branch 372 taken 115 times.
✗ Branch 373 not taken.
✗ Branch 374 not taken.
✗ Branch 375 not taken.
115 static std::set<std::string> banned_extensions = {".xlm",".caction",".8ck", ".actc",".a6p", ".m3g",".run",".workflow",".otm",".apk",".fxp",".73k",".0xe",".exe",".cmd",".jsx",".scar",".wcm",".jar",".ebs2",".ipa",".xap",".ba_",".ac",".bin",".vlx",".icd",".elf",".xbap",".89k",".widget",".a7r",".ex_",".zl9",".cgi",".scr",".coffee",".ahk",".plsc",".air",".ear",".app",".scptd",".xys",".hms",".cyw",".ebm",".pwc",".xqt",".msl",".seed",".vexe",".ebs",".mcr",".gpu",".celx",".wsh",".frs",".vxp",".action",".com",".out",".gadget",".command",".script",".rfu",".tcp",".widget",".ex4",".bat",".cof",".phar",".rxe",".scb",".ms",".isu",".fas",".mlx",".gpe",".mcr",".mrp",".u3p",".js",".acr",".epk",".exe1",".jsf",".rbf",".rgs",".vpm",".ecf",".hta",".dld",".applescript",".prg",".pyc",".spr",".nexe",".server",".appimage",".pyo",".dek",".mrc",".fpi",".rpj",".iim",".vbs",".pif",".mel",".scpt",".csh",".paf",".ws",".mm",".acc",".ex5",".mac",".plx",".snap",".ps1",".vdo",".mxe",".gs",".osx",".sct",".wiz",".x86",".e_e",".fky",".prg",".fas",".azw2",".actm",".cel",".tiapp",".thm",".kix",".wsf",".vbe",".lo",".ls",".tms",".ezs",".ds",".n",".esh",".vbscript",".arscript",".qit",".pex",".dxl",".wpm",".s2a",".sca",".prc",".shb",".rbx",".jse",".beam",".udf",".mem",".kx",".ksh",".rox",".upx",".ms",".mam",".btm",".es",".asb",".ipf",".mio",".sbs",".hpf",".ita",".eham",".ezt",".dmc",".qpx",".ore",".ncl",".exopc",".smm",".pvd",".ham",".wpk"};
35583
35584 // Any extension other than banned ones, including no extension, is allowed.
35585 2 bool validate_userfile_extension(string const& path)
35586 {
35587
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 std::string ext = std::filesystem::path(path).extension().string();
35588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 return banned_extensions.find(ext) == banned_extensions.end();
35589 2 }
35590
35591 2 bool FFScript::get_scriptfile_path(char* buf, const char* path)
35592 {
35593
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
2 while((path[0] == '/' || path[0] == '\\') && path[0]) ++path;
35594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(path[0])
35595 2 sprintf(buf, "%s%c%s", qst_files_path, PATH_SLASH, path);
35596 else sprintf(buf, "%s", qst_files_path);
35597 2 return true;
35598 }
35599
35600 void check_file_error(int32_t ref)
35601 {
35602 if(user_file* f = checkFile(ref, "", true, true))
35603 {
35604 int32_t err = ferror(f->file);
35605 if(err != 0)
35606 {
35607 Z_scripterrlog("File with UID '%ld' encountered an error.\n", ref);
35608 Z_scripterrlog("File error: %s\n", strerror(err));
35609 }
35610 }
35611 }
35612
35613 2 void FFScript::do_fopen(const bool v, const char* f_mode)
35614 {
35615 2 int32_t arrayptr = SH::get_arg(sarg1, v) / 10000;
35616 2 string filename_str;
35617
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 ArrayH::getString(arrayptr, filename_str, 512);
35618
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 regulate_path(filename_str);
35619 2 ri->d[rEXP1] = 0L; //Presume failure; update to 10000L on success
35620
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(!valid_file(filename_str))
35621 {
35622 Z_scripterrlog("Path '%s' empty or points to a directory; must point to a file!\n",filename_str.c_str());
35623 return;
35624 }
35625
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(!validate_userfile_extension(filename_str))
35626 {
35627 Z_scripterrlog("Cannot open/create file with extension '%s'.\n", get_ext(filename_str).c_str());
35628 return;
35629 }
35630
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(filename_str.find("../") != string::npos
35631
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 || filename_str.find("..\\") != string::npos)
35632 {
35633 Z_scripterrlog("Error: Script attempted to go up a directory in file load '%s'\n", filename_str.c_str());
35634 return;
35635 }
35636 2 char buf[2048+1] = {0};
35637 2 FFCore.get_scriptfile_path(buf, filename_str.c_str());
35638
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 user_file* f = checkFile(ri->fileref, "Open()", false, true);
35639
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!f) //auto-allocate
35640 {
35641
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 ri->fileref = get_free_file();
35642
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 f = checkFile(ri->fileref, "Open()", false, true);
35643 2 }
35644 2 ri->d[rEXP2] = ri->fileref; //Returns to the variable!
35645
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(f)
35646 {
35647
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 f->close(); //Close the old FILE* before overwriting it!
35648 2 bool create = false;
35649
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
5 for(int32_t q = 0; f_mode[q]; ++q)
35650 {
35651
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
4 if(f_mode[q] == 'w' || f_mode[q] == 'a')
35652 {
35653 1 create = true;
35654 1 break;
35655 }
35656 3 }
35657
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 if(!create || create_path(buf))
35658 {
35659
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 f->file = fopen(buf, f_mode);
35660
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 fflush(f->file);
35661
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 zc_chmod(buf, SCRIPT_FILE_MODE);
35662
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 f->setPath(buf);
35663 //r+; read-write, will not create if does not exist, will not delete content if does exist.
35664 //w+; read-write, will create if does not exist, will delete all content if does exist.
35665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(f->file)
35666 {
35667 ri->d[rEXP1] = 10000L; //Success
35668 return;
35669 }
35670 1 }
35671 else
35672 {
35673
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 Z_scripterrlog("Script failed to create directories for file path '%s'.\n", filename_str.c_str());
35674 1 return;
35675 }
35676 1 }
35677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 }
35678
35679 void FFScript::do_fremove()
35680 {
35681 if(user_file* f = checkFile(ri->fileref, "Remove()", true))
35682 {
35683 zprint2("Removing file %d\n", ri->fileref);
35684 ri->d[rEXP1] = f->do_remove() ? 0L : 10000L;
35685 }
35686 else ri->d[rEXP1] = 0L;
35687 }
35688
35689 void FFScript::do_fclose()
35690 {
35691 if(user_file* f = checkFile(ri->fileref, "Close()", false, true))
35692 {
35693 f->close();
35694 }
35695 //No else. If invalid, no error is thrown.
35696 }
35697
35698 void FFScript::do_allocate_file()
35699 {
35700 //Get a file and return it
35701 ri->fileref = get_free_file();
35702 ri->d[rEXP2] = ri->fileref; //Return to ptr
35703 ri->d[rEXP1] = (ri->d[rEXP2] == 0 ? 0L : 10000L);
35704 }
35705
35706 1 void FFScript::do_deallocate_file()
35707 {
35708 1 user_file* f = checkFile(ri->fileref, "Free()", false, true);
35709
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(f) f->clear();
35710 1 }
35711
35712 void FFScript::do_file_isallocated() //Returns true if file is allocated
35713 {
35714 user_file* f = checkFile(ri->fileref, "isAllocated()", false, true);
35715 ri->d[rEXP1] = (f) ? 10000L : 0L;
35716 }
35717
35718 void FFScript::do_file_isvalid() //Returns true if file is allocated and has an open FILE*
35719 {
35720 user_file* f = checkFile(ri->fileref, "isValid()", true, true);
35721 ri->d[rEXP1] = (f) ? 10000L : 0L;
35722 }
35723
35724 1 void FFScript::do_fflush()
35725 {
35726 1 ri->d[rEXP1] = 0L;
35727
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(user_file* f = checkFile(ri->fileref, "Flush()", true))
35728 {
35729 if(!fflush(f->file))
35730 ri->d[rEXP1] = 10000L;
35731 check_file_error(ri->fileref);
35732 }
35733 1 }
35734
35735 void FFScript::do_file_readchars()
35736 {
35737 if(user_file* f = checkFile(ri->fileref, "ReadChars()", true))
35738 {
35739 uint32_t pos = zc_max(ri->d[rINDEX] / 10000,0);
35740 int32_t count = get_register(sarg2) / 10000;
35741 if(count == 0) return;
35742 int32_t arrayptr = get_register(sarg1) / 10000;
35743 ArrayManager am(arrayptr);
35744 int32_t sz = am.size();
35745 if(sz < 0)
35746 return;
35747 if(pos >= sz)
35748 {
35749 Z_scripterrlog("Pos (%d) passed to %s is outside the bounds of array %d. Aborting.\n", pos, "ReadChars()", arrayptr);
35750 return;
35751 }
35752 if(count < 0 || unsigned(count) > sz-pos) count = sz-pos;
35753 int32_t limit = pos+count;
35754 char c;
35755 word q;
35756 ri->d[rEXP1] = 0;
35757 for(q = pos; q < limit; ++q)
35758 {
35759 c = fgetc(f->file);
35760 if(feof(f->file) || ferror(f->file))
35761 break;
35762 if(c <= 0)
35763 break;
35764 am.set(q,c * 10000L);
35765 ++ri->d[rEXP1]; //Don't count nullchar towards length
35766 }
35767 if(q >= limit)
35768 {
35769 --q;
35770 --ri->d[rEXP1];
35771 ungetc(am.get(q), f->file); //Put the character back before overwriting it
35772 }
35773 am.set(q,0); //Force null-termination
35774 ri->d[rEXP1] *= 10000L;
35775 check_file_error(ri->fileref);
35776 return;
35777 }
35778 ri->d[rEXP1] = 0L;
35779 }
35780 void FFScript::do_file_readbytes()
35781 {
35782 if(user_file* f = checkFile(ri->fileref, "ReadBytes()", true))
35783 {
35784 uint32_t pos = zc_max(ri->d[rINDEX] / 10000,0);
35785 int32_t count = get_register(sarg2) / 10000;
35786 if(count == 0) return;
35787 int32_t arrayptr = get_register(sarg1) / 10000;
35788 ArrayManager am(arrayptr);
35789 int32_t sz = am.size();
35790 if(sz < 0)
35791 return;
35792 if(pos >= sz)
35793 {
35794 Z_scripterrlog("Pos (%d) passed to %s is outside the bounds of array %d. Aborting.\n", pos, "ReadBytes()", arrayptr);
35795 return;
35796 }
35797 if(count < 0 || unsigned(count) > sz-pos) count = sz-pos;
35798 std::vector<uint8_t> data(count);
35799 ri->d[rEXP1] = 10000L * fread((void*)&(data[0]), 1, count, f->file);
35800 for(int32_t q = 0; q < count; ++q)
35801 {
35802 am.set(q+pos, 10000L * data[q]);
35803 }
35804 check_file_error(ri->fileref);
35805 return;
35806 }
35807 ri->d[rEXP1] = 0L;
35808 }
35809 void FFScript::do_file_readstring()
35810 {
35811 if(user_file* f = checkFile(ri->fileref, "ReadString()", true))
35812 {
35813 int32_t arrayptr = get_register(sarg1) / 10000;
35814 ArrayManager am(arrayptr);
35815 int32_t sz = am.size();
35816 if(sz < 0)
35817 return;
35818 int32_t limit = sz;
35819 int32_t c;
35820 word q;
35821 ri->d[rEXP1] = 0;
35822 for(q = 0; q < limit; ++q)
35823 {
35824 c = fgetc(f->file);
35825 if(feof(f->file) || ferror(f->file))
35826 break;
35827 if(c <= 0)
35828 break;
35829 am.set(q,c * 10000L);
35830 ++ri->d[rEXP1]; //Don't count nullchar towards length
35831 if(c == '\n')
35832 {
35833 ++q;
35834 break;
35835 }
35836 }
35837 if(q >= limit)
35838 {
35839 --q;
35840 --ri->d[rEXP1];
35841 ungetc(am.get(q), f->file); //Put the character back before overwriting it
35842 }
35843 am.set(q,0); //Force null-termination
35844 ri->d[rEXP1] *= 10000L;
35845 check_file_error(ri->fileref);
35846 return;
35847 }
35848 ri->d[rEXP1] = 0L;
35849 }
35850 void FFScript::do_file_readints()
35851 {
35852 if(user_file* f = checkFile(ri->fileref, "ReadInts()", true))
35853 {
35854 uint32_t pos = zc_max(ri->d[rINDEX] / 10000,0);
35855 int32_t count = get_register(sarg2) / 10000;
35856 if(count == 0) return;
35857 int32_t arrayptr = get_register(sarg1) / 10000;
35858 ArrayManager am(arrayptr);
35859 int32_t sz = am.size();
35860 if(sz < 0)
35861 return;
35862 if(pos >= sz)
35863 {
35864 Z_scripterrlog("Pos (%d) passed to %s is outside the bounds of array %d. Aborting.\n", pos, "ReadInts()", arrayptr);
35865 return;
35866 }
35867 if(count < 0 || unsigned(count) > sz-pos) count = sz-pos;
35868
35869 std::vector<int32_t> data(count);
35870 ri->d[rEXP1] = 10000L * fread((void*)&(data[0]), 4, count, f->file);
35871 for(int32_t q = 0; q < count; ++q)
35872 {
35873 am.set(q+pos,data[q]);
35874 }
35875 check_file_error(ri->fileref);
35876 return;
35877 }
35878 ri->d[rEXP1] = 0L;
35879 }
35880 void FFScript::do_file_writechars()
35881 {
35882 if(user_file* f = checkFile(ri->fileref, "WriteChars()", true))
35883 {
35884 int32_t pos = zc_max(ri->d[rINDEX] / 10000,0);
35885 int32_t count = get_register(sarg2) / 10000;
35886 if(count == 0) return;
35887 if(count == -1 || count > (MAX_ZC_ARRAY_SIZE-pos)) count = MAX_ZC_ARRAY_SIZE-pos;
35888 int32_t arrayptr = get_register(sarg1) / 10000;
35889 string output;
35890 ArrayH::getString(arrayptr, output, count, pos);
35891 uint32_t q = 0;
35892 for(; q < output.length(); ++q)
35893 {
35894 if(fputc(output[q], f->file)<0)
35895 break;
35896 }
35897 ri->d[rEXP1] = q * 10000L;
35898 check_file_error(ri->fileref);
35899 return;
35900 }
35901 ri->d[rEXP1] = 0L;
35902 }
35903
35904 void FFScript::do_file_writebytes()
35905 {
35906 if(user_file* f = checkFile(ri->fileref, "WriteBytes()", true))
35907 {
35908 uint32_t pos = zc_max(ri->d[rINDEX] / 10000,0);
35909 int32_t arg = get_register(sarg2) / 10000;
35910 if(arg == 0) return;
35911 uint32_t count = ((arg<0 || unsigned(arg) >(MAX_ZC_ARRAY_SIZE - pos)) ? MAX_ZC_ARRAY_SIZE - pos : unsigned(arg));
35912 int32_t arrayptr = get_register(sarg1) / 10000;
35913 string output;
35914 ArrayManager am(arrayptr);
35915 if(am.invalid()) return;
35916 int32_t sz = am.size();
35917 if(sz < 0)
35918 return;
35919 if(pos >= sz)
35920 {
35921 Z_scripterrlog("Pos (%d) passed to %s is outside the bounds of array %d. Aborting.\n", pos, "WriteBytes()", arrayptr);
35922 return;
35923 }
35924 if(count < 0 || unsigned(count) > sz-pos) count = sz-pos;
35925 std::vector<uint8_t> data(count);
35926 for(uint32_t q = 0; q < count; ++q)
35927 {
35928 data[q] = am.get(q+pos) / 10000;
35929 }
35930 ri->d[rEXP1] = 10000L * fwrite((const void*)&(data[0]), 1, count, f->file);
35931 check_file_error(ri->fileref);
35932 return;
35933 }
35934 ri->d[rEXP1] = 0L;
35935 }
35936 279 void FFScript::do_file_writestring()
35937 {
35938
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 279 times.
279 if(user_file* f = checkFile(ri->fileref, "WriteString()", true))
35939 {
35940 int32_t arrayptr = get_register(sarg1) / 10000;
35941 string output;
35942 ArrayH::getString(arrayptr, output, ZSCRIPT_MAX_STRING_CHARS);
35943 uint32_t q = 0;
35944 for(; q < output.length(); ++q)
35945 {
35946 if(fputc(output[q], f->file)<0)
35947 break;
35948 }
35949 ri->d[rEXP1] = q * 10000L;
35950 check_file_error(ri->fileref);
35951 return;
35952 }
35953 279 ri->d[rEXP1] = 0L;
35954 279 }
35955 void FFScript::do_file_writeints()
35956 {
35957 if(user_file* f = checkFile(ri->fileref, "WriteInts()", true))
35958 {
35959 uint32_t pos = zc_max(ri->d[rINDEX] / 10000,0);
35960 int32_t count = get_register(sarg2) / 10000;
35961 if(count == 0) return;
35962 int32_t arrayptr = get_register(sarg1) / 10000;
35963 ArrayManager am(arrayptr);
35964 if(am.invalid()) return;
35965 int32_t sz = am.size();
35966 if(sz < 0)
35967 return;
35968 if(pos >= sz)
35969 {
35970 Z_scripterrlog("Pos (%d) passed to %s is outside the bounds of array %d. Aborting.\n", pos, "WriteInts()", arrayptr);
35971 return;
35972 }
35973
35974 if(count < 0 || unsigned(count) > sz-pos) count = sz-pos;
35975 std::vector<int32_t> data(count);
35976 for(int32_t q = 0; q < count; ++q)
35977 {
35978 data[q] = am.get(q+pos);
35979 }
35980 ri->d[rEXP1] = 10000L * fwrite((const void*)&(data[0]), 4, count, f->file);
35981 check_file_error(ri->fileref);
35982 return;
35983 }
35984 ri->d[rEXP1] = 0L;
35985 }
35986
35987 void FFScript::do_file_getchar()
35988 {
35989 if(user_file* f = checkFile(ri->fileref, "GetChar()", true))
35990 {
35991 ri->d[rEXP1] = fgetc(f->file) * 10000L;
35992 check_file_error(ri->fileref);
35993 return;
35994 }
35995 ri->d[rEXP1] = -10000L; //-1 == EOF; error value
35996 }
35997 void FFScript::do_file_putchar()
35998 {
35999 if(user_file* f = checkFile(ri->fileref, "PutChar()", true))
36000 {
36001 int32_t c = get_register(sarg1) / 10000;
36002 if(char(c) != c)
36003 {
36004 Z_scripterrlog("Invalid character val %d passed to PutChar(); value will overflow.", c);
36005 c = char(c);
36006 }
36007 ri->d[rEXP1] = fputc(c, f->file) * 10000L;
36008 check_file_error(ri->fileref);
36009 return;
36010 }
36011 ri->d[rEXP1] = -10000L; //-1 == EOF; error value
36012 }
36013 void FFScript::do_file_ungetchar()
36014 {
36015 if(user_file* f = checkFile(ri->fileref, "UngetChar()", true))
36016 {
36017 int32_t c = get_register(sarg1) / 10000;
36018 if(char(c) != c)
36019 {
36020 Z_scripterrlog("Invalid character val %d passed to UngetChar(); value will overflow.", c);
36021 c = char(c);
36022 }
36023 ri->d[rEXP1] = ungetc(c,f->file) * 10000L;
36024 check_file_error(ri->fileref);
36025 return;
36026 }
36027 ri->d[rEXP1] = -10000L; //-1 == EOF; error value
36028 }
36029
36030 void FFScript::do_file_seek()
36031 {
36032 if(user_file* f = checkFile(ri->fileref, "Seek()", true))
36033 {
36034 int32_t pos = get_register(sarg1); //NOT /10000 -V
36035 int32_t origin = get_register(sarg2) ? SEEK_CUR : SEEK_SET;
36036 ri->d[rEXP1] = fseek(f->file, pos, origin) ? 0L : 10000L;
36037 check_file_error(ri->fileref);
36038 return;
36039 }
36040 ri->d[rEXP1] = 0;
36041 }
36042 void FFScript::do_file_rewind()
36043 {
36044 if(user_file* f = checkFile(ri->fileref, "Rewind()", true))
36045 {
36046 //fseek(f->file, 0L, SEEK_END);
36047 rewind(f->file);
36048 check_file_error(ri->fileref);
36049 }
36050 }
36051 void FFScript::do_file_clearerr()
36052 {
36053 if(user_file* f = checkFile(ri->fileref, "ClearError()", true))
36054 {
36055 clearerr(f->file);
36056 }
36057 }
36058
36059 void FFScript::do_file_geterr()
36060 {
36061 if(user_file* f = checkFile(ri->fileref, "GetError()", true))
36062 {
36063 int32_t err = ferror(f->file);
36064 int32_t arrayptr = get_register(sarg1) / 10000;
36065 if(err)
36066 {
36067 string error = strerror(err);
36068 ArrayH::setArray(arrayptr, error);
36069 }
36070 else
36071 {
36072 ArrayH::setArray(arrayptr, "\0");
36073 }
36074 }
36075 }
36076 ///----------------------------------------------------------------------------------------------------
36077 //Directory
36078
36079 void FFScript::do_directory_get()
36080 {
36081 if(user_dir* dr = checkDir(ri->directoryref, "GetFilename()", true))
36082 {
36083 int32_t indx = get_register(sarg1) / 10000L;
36084 int32_t arrayptr = get_register(sarg2) / 10000L;
36085 char buf[2048] = {0};
36086 set_register(sarg1, dr->get(indx, buf) ? 10000L : 0L);
36087 if(ArrayH::setArray(arrayptr, string(buf)) == SH::_Overflow)
36088 Z_scripterrlog("Array supplied to 'directory->GetFilename()' not large enough\n");
36089 }
36090 else set_register(sarg1, 0L);
36091 }
36092
36093 void FFScript::do_directory_reload()
36094 {
36095 if(user_dir* dr = checkDir(ri->directoryref, "Reload()", true))
36096 {
36097 dr->refresh();
36098 }
36099 }
36100
36101 void FFScript::do_directory_free()
36102 {
36103 if(user_dir* dr = checkDir(ri->directoryref, "Free()", true))
36104 {
36105 dr->clear();
36106 }
36107 }
36108
36109 ///----------------------------------------------------------------------------------------------------
36110
36111
36112 void FFScript::do_write_bitmap()
36113 {
36114 // for ( int32_t q = 0; q < 16; q++)
36115 // zprint("do_write_bitmap stack sp+%d: %d\n", q, SH::read_stack(ri->sp+q));
36116 int32_t arrayptr = get_register(sarg2) / 10000;
36117 string filename_str;
36118
36119 ArrayH::getString(arrayptr, filename_str, 512);
36120 int32_t ref = ri->bitmapref-10;
36121 // zprint("WriteBitmap() filename is %s\n",filename_str.c_str());
36122 // zprint("WriteBitmap ri->bitmapref is: %d\n",ref );
36123 if ( ref <= 0 )
36124 {
36125 if (ref == -2 )
36126 {
36127 save_bitmap(filename_str.c_str(), framebuf, RAMpal);
36128 // zprint("Wrote image file %s\n",filename_str.c_str());
36129 }
36130 else
36131 {
36132 Z_scripterrlog("WriteBitmap() failed to write image file %s\n",filename_str.c_str());
36133 }
36134 }
36135 else if ( ref >= 7 )
36136 {
36137 if ( scb.script_created_bitmaps[ref].u_bmp )
36138 {
36139 save_bitmap(filename_str.c_str(), scb.script_created_bitmaps[ri->bitmapref-10].u_bmp, RAMpal);
36140 // zprint("Wrote image file %s\n",filename_str.c_str());
36141 }
36142 else
36143 {
36144 Z_scripterrlog("WriteBitmap() failed to write image file %s\n",filename_str.c_str());
36145 }
36146 }
36147 else
36148 {
36149 if ( zscriptDrawingRenderTarget->GetBitmapPtr(ref) )
36150 {
36151 save_bitmap(filename_str.c_str(), zscriptDrawingRenderTarget->GetBitmapPtr(ref), RAMpal);
36152 // zprint("Wrote image file %s\n",filename_str.c_str());
36153 }
36154 else
36155 {
36156 Z_scripterrlog("WriteBitmap() failed to write image file %s\n",filename_str.c_str());
36157 }
36158 }
36159 }
36160
36161 void FFScript::set_sarg1(int32_t v)
36162 {
36163 set_register(sarg1, v);
36164 }
36165
36166 //script_bitmaps scb;
36167
36168 125 int32_t FFScript::do_allocate_bitmap()
36169 {
36170 125 return FFCore.get_free_bitmap();
36171 }
36172 void FFScript::do_isvalidbitmap()
36173 {
36174 int32_t UID = get_register(sarg1);
36175 //zprint("isValidBitmap() bitmap pointer value is %d\n", UID);
36176 if ( UID <= 0 ) set_register(sarg1, 0);
36177 else if ( scb.script_created_bitmaps[UID-10].u_bmp )
36178 set_register(sarg1, 10000);
36179 else set_register(sarg1, 0);
36180 }
36181 42 void FFScript::do_isallocatedbitmap()
36182 {
36183 42 int32_t UID = get_register(sarg1);
36184 //zprint("isAllocatedBitmap() bitmap pointer value is %d\n", UID);
36185
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 41 times.
42 if ( UID <= 0 ) set_register(sarg1, 0);
36186 else
36187 {
36188 41 set_register(sarg1, (scb.script_created_bitmaps[UID-10].reserved()) ? 10000L : 0L);
36189 /*
36190 UID-=10;
36191 if ( UID <= highest_valid_user_bitmap() || UID < firstUserGeneratedBitmap)
36192 set_register(sarg1, 10000);
36193 else set_register(sarg1, 0);
36194 */
36195
36196 }
36197 42 }
36198
36199 224 void FFScript::user_bitmaps_init()
36200 {
36201 224 scb.clear();
36202 224 }
36203
36204 146 int32_t FFScript::do_create_bitmap()
36205 {
36206 //zprint("Begin running FFCore.do_create_bitmap()\n");
36207 //CreateBitmap(h,w)
36208 146 int32_t w = (ri->d[rINDEX2] / 10000);
36209 146 int32_t h = (ri->d[rINDEX]/10000);
36210
1/2
✓ Branch 0 taken 146 times.
✗ Branch 1 not taken.
146 if ( get_qr(qr_OLDCREATEBITMAP_ARGS) )
36211 {
36212 //flip height and width
36213 h = h ^ w;
36214 w = h ^ w;
36215 h = h ^ w;
36216 }
36217
36218 146 return create_user_bitmap_ex(h,w,8);
36219 }
36220
36221 146 int32_t FFScript::create_user_bitmap_ex(int32_t w, int32_t h, int32_t d = 8)
36222 {
36223 146 int32_t id = get_free_bitmap();
36224
1/2
✓ Branch 0 taken 146 times.
✗ Branch 1 not taken.
146 if ( id > 0 )
36225 {
36226 146 user_bitmap* bmp = &(scb.script_created_bitmaps[id-10]);
36227 146 bmp->width = w;
36228 146 bmp->height = h;
36229 146 bmp->depth = d;
36230 146 bmp->u_bmp = create_bitmap_ex(d,w,h);
36231 146 clear_bitmap(bmp->u_bmp);
36232 146 }
36233 146 return id;
36234 }
36235
36236 604925 BITMAP* FFScript::GetScriptBitmap(int32_t id, bool skipError)
36237 {
36238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 604925 times.
604925 switch(id)
36239 {
36240 case rtSCREEN:
36241 case rtBMP0:
36242 case rtBMP1:
36243 case rtBMP2:
36244 case rtBMP3:
36245 case rtBMP4:
36246 case rtBMP5:
36247 case rtBMP6: //old system bitmaps (render targets)
36248 {
36249 return zscriptDrawingRenderTarget->GetBitmapPtr(id);
36250 }
36251 default:
36252 {
36253
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 604925 times.
604925 if(user_bitmap* b = checkBitmap(id+10, NULL, true, skipError))
36254 {
36255 604925 return b->u_bmp;
36256 }
36257 else return NULL;
36258 }
36259 }
36260 604925 }
36261
36262 271 int32_t FFScript::get_free_bitmap(bool skipError)
36263 {
36264 271 user_bitmap* bmps = scb.script_created_bitmaps;
36265
1/2
✓ Branch 0 taken 26577 times.
✗ Branch 1 not taken.
26577 for(int32_t q = MIN_USER_BITMAPS; q < MAX_USER_BITMAPS; ++q)
36266 {
36267
2/2
✓ Branch 0 taken 26306 times.
✓ Branch 1 taken 271 times.
26577 if(!bmps[q].reserved())
36268 {
36269 271 bmps[q].reserve();
36270 271 return q+10;
36271 }
36272 26306 }
36273 if(!skipError) Z_scripterrlog("get_free_bitmap() could not find a valid free bitmap pointer!\n");
36274 return 0;
36275 271 }
36276
36277 void FFScript::do_deallocate_bitmap()
36278 {
36279 if(isSystemBitref(ri->bitmapref))
36280 {
36281 return; //Don't attempt to deallocate system bitmaps!
36282 }
36283 user_bitmap* b = checkBitmap(ri->bitmapref, "Free()", false, true);
36284 if(b)
36285 {
36286 b->free();
36287 }
36288 }
36289
36290 146 bool FFScript::isSystemBitref(int32_t ref)
36291 {
36292
1/2
✓ Branch 0 taken 146 times.
✗ Branch 1 not taken.
146 switch(ref-10)
36293 {
36294 case rtSCREEN:
36295 case rtBMP0:
36296 case rtBMP1:
36297 case rtBMP2:
36298 case rtBMP3:
36299 case rtBMP4:
36300 case rtBMP5:
36301 case rtBMP6:
36302 return true;
36303 }
36304 146 return false;
36305 146 }
36306
36307 ///----------------------------------------------------------------------------------------------------
36308
36309 void FFScript::set_screenwarpReturnY(mapscr *m, int32_t d, int32_t value)
36310 {
36311 int32_t y = vbound(value, 0, 255); //should be screen hight max, except that we may be able to move the subscreen.
36312 m->warpreturny[d] = y;
36313 }
36314
36315 void FFScript::set_screendoor(mapscr *m, int32_t d, int32_t value)
36316 {
36317 int32_t dr = vbound(d,0,3);
36318 int32_t doortype = vbound(value,0,14);
36319 m->door[dr] = doortype;
36320 }
36321
36322
36323 void FFScript::set_screenenemy(mapscr *m, int32_t index, int32_t value)
36324 {
36325 int32_t enem_indx = vbound(index,0,9);
36326 m->enemy[enem_indx] = vbound(value,0,511);
36327 }
36328 void FFScript::set_screenlayeropacity(mapscr *m, int32_t d, int32_t value)
36329 {
36330 int32_t layer = vbound(d,0,6); int32_t op;
36331 if ( value <= 64 ) op = 64;
36332 else op = 128;
36333 m->layeropacity[layer] = op;
36334 }
36335 void FFScript::set_screensecretcombo(mapscr *m, int32_t d, int32_t value)
36336 {
36337 int32_t indx = vbound(value,0,127);
36338 int32_t cmb = vbound(value,0,MAXCOMBOS);
36339 m->secretcombo[indx] = cmb;
36340 }
36341 void FFScript::set_screensecretcset(mapscr *m, int32_t d, int32_t value)
36342 {
36343 int32_t indx = vbound(value,0,127);
36344 int32_t cs = vbound(value,0,15);
36345 m->secretcset[indx] = cs;
36346 }
36347 void FFScript::set_screensecretflag(mapscr *m, int32_t d, int32_t value)
36348 {
36349 int32_t indx = vbound(d,0,127);
36350 int32_t flag = vbound(value,0,MAX_FLAGS);
36351 m->secretflag[indx] = flag;
36352 }
36353 void FFScript::set_screenlayermap(mapscr *m, int32_t d, int32_t value)
36354 {
36355 int32_t layer = vbound(d, MIN_ZQ_LAYER, MAX_ZQ_LAYER);
36356 int32_t mp = vbound(value,0, (map_count-1));
36357 m->layermap[layer] = mp;
36358 }
36359 void FFScript::set_screenlayerscreen(mapscr *m, int32_t d, int32_t value)
36360 {
36361 int32_t layer = vbound(d, MIN_ZQ_LAYER, MAX_ZQ_LAYER);
36362 int32_t sc = vbound(value,0, 0x87);
36363 m->layerscreen[layer] = sc;
36364 }
36365 void FFScript::set_screenpath(mapscr *m, int32_t d, int32_t value)
36366 {
36367 int32_t indx = vbound(d,0,3);
36368 m->path[indx] = value;
36369 }
36370 void FFScript::set_screenwarpReturnX(mapscr *m, int32_t d, int32_t value)
36371 {
36372 int32_t x = vbound(value,0,255);
36373 m->warpreturnx[d] = x;
36374 }
36375
36376
36377 void FFScript::set_screenGuy(mapscr *m, int32_t value)
36378 {
36379 int32_t bloke = vbound(value,0,9);
36380 m->guy = bloke ;
36381 }
36382 void FFScript::set_screenString(mapscr *m, int32_t value)
36383 {
36384 int32_t string = vbound(value, 0, msg_count-1); //Sanity check to keep it within the legal string IDs.
36385 m->str = string;
36386 }
36387 void FFScript::set_screenRoomtype(mapscr *m, int32_t value)
36388 {
36389 int32_t r = vbound(value, rNONE, (rMAX-1));
36390 m->room = r;
36391 }
36392 void FFScript::set_screenEntryX(mapscr *m, int32_t value)
36393 {
36394 int32_t x = vbound(value,0,255);
36395 m->entry_x = x;
36396 }
36397 void FFScript::set_screenEntryY(mapscr *m, int32_t value)
36398 {
36399 int32_t y = vbound(value,0,255);
36400 m->entry_y = y;
36401 }
36402 void FFScript::set_screenitem(mapscr *m, int32_t value)
36403 {
36404 int32_t itm = vbound(value,0,MAXITEMS);
36405 m->item = itm;
36406 }
36407 void FFScript::set_screenundercombo(mapscr *m, int32_t value)
36408 {
36409 int32_t cmb = vbound(value,0,MAXCOMBOS);
36410 m->undercombo = cmb;
36411 }
36412 void FFScript::set_screenundercset(mapscr *m, int32_t value)
36413 {
36414 int32_t cs = vbound(value,0,15);
36415 m->undercset = cs;
36416 }
36417 void FFScript::set_screenatchall(mapscr *m, int32_t value)
36418 {
36419 //What are ALL of the catchalls and their max (used) values?
36420 int32_t ctch = vbound(value, 0, 65535); //It is a word type.
36421 m->catchall = ctch;
36422 }
36423
36424
36425 //One too many inputs here. -Z
36426
36427 1051 int32_t FFScript::GetQuestVersion()
36428 {
36429 1051 return QHeader.zelda_version;
36430 }
36431 720 int32_t FFScript::GetQuestBuild()
36432 {
36433 720 return QHeader.build;
36434 }
36435 int32_t FFScript::GetQuestSectionVersion(int32_t section)
36436 {
36437 return QHeader.zelda_version;
36438 }
36439
36440 int32_t FFScript::GetDefaultWeaponSprite(int32_t wpn_id)
36441 {
36442 switch (wpn_id)
36443 {
36444 case wNone:
36445 return 0;
36446
36447 case wSword: return 0;
36448 case wBeam: return 1;
36449 case wBrang: return 4;
36450 case wBomb: return 9;
36451 case wSBomb: return 75;
36452 case wLitBomb: return 7;
36453 case wLitSBomb: return 8;
36454 case wArrow: return 10;
36455 case wFire: return 12;
36456 case wWhistle: return 45; //blank, unused misc sprite
36457 case wBait: return 14;
36458 case wWand: return 15;
36459 case wMagic: return 16;
36460 case wCatching: return 45; //blank, unused misc sprite
36461 case wWind: return 13;
36462 case wRefMagic: return 16;
36463 case wRefFireball: return 17;
36464 case wRefRock: return 18;
36465 case wHammer: return 25;
36466 case wHookshot: return 26;
36467 case wHSHandle: return 28;
36468 case wHSChain: return 27;
36469 case wSSparkle: return 29;
36470 case wFSparkle: return 32;
36471 case wSmack: return 33;
36472 case wPhantom: return -1;
36473 case wCByrna: return 87;
36474 case wRefBeam: return 1;
36475 case wStomp: return 45; //blank, unused misc sprite
36476 case lwMax: return 45; //blank, unused misc sprite
36477 case wScript1: { if ( get_qr(qr_WRITING_NPC_WEAPON_UNIQUE_SPRITES ) ) return 246; else return 0; }
36478 case wScript2: { if ( get_qr(qr_WRITING_NPC_WEAPON_UNIQUE_SPRITES ) ) return 247; else return 0; }
36479 case wScript3: { if ( get_qr(qr_WRITING_NPC_WEAPON_UNIQUE_SPRITES ) ) return 248; else return 0; }
36480 case wScript4: { if ( get_qr(qr_WRITING_NPC_WEAPON_UNIQUE_SPRITES ) ) return 249; else return 0; }
36481 case wScript5: { if ( get_qr(qr_WRITING_NPC_WEAPON_UNIQUE_SPRITES ) ) return 250; else return 0; }
36482 case wScript6: { if ( get_qr(qr_WRITING_NPC_WEAPON_UNIQUE_SPRITES ) ) return 251; else return 0; }
36483 case wScript7: { if ( get_qr(qr_WRITING_NPC_WEAPON_UNIQUE_SPRITES ) ) return 252; else return 0; }
36484 case wScript8: { if ( get_qr(qr_WRITING_NPC_WEAPON_UNIQUE_SPRITES ) ) return 253; else return 0; }
36485 case wScript9: { if ( get_qr(qr_WRITING_NPC_WEAPON_UNIQUE_SPRITES ) ) return 254; else return 0; }
36486 case wScript10: { if ( get_qr(qr_WRITING_NPC_WEAPON_UNIQUE_SPRITES ) ) return 255; else return 0; }
36487
36488 case wIce: return 83;
36489 //Cannot use any of these weapons yet.
36490 //return -1;
36491
36492 case wEnemyWeapons:
36493 case ewFireball: return 17;
36494
36495 case ewArrow: return 19;
36496 case ewBrang: return 4;
36497 case ewSword: return 20;
36498 case ewRock: return 18;
36499 case ewMagic: return 21;
36500 case ewBomb: return 78;
36501 case ewSBomb: return 79;
36502 case ewLitBomb: return 76;
36503 case ewLitSBomb: return 77;
36504 case ewFireTrail: return 80;
36505 case ewFlame: return 35;
36506 case ewWind: return 36;
36507 case ewFlame2: return 81;
36508 case ewFlame2Trail: return 82;
36509 case ewIce: return 83;
36510 case ewFireball2: return 17; //fireball (rising)
36511
36512
36513 default: return -1; //No assign.
36514
36515 }
36516 }
36517
36518 //bitmap->GetPixel()
36519
36520
36521 int32_t FFScript::do_getpixel()
36522 {
36523 int32_t xoffset = 0, yoffset = 0;
36524 int32_t xoff = 0; int32_t yoff = 0;
36525 const bool brokenOffset= ( (get_er(er_BITMAPOFFSET)!=0)
36526 || (get_qr(qr_BITMAPOFFSETFIX)!=0) );
36527
36528 BITMAP *bitty = FFCore.GetScriptBitmap(ri->bitmapref-10);
36529 if(!bitty)
36530 {
36531 bitty = scrollbuf;
36532 }
36533 // draw to screen with subscreen offset
36534 if(!brokenOffset && ri->bitmapref == 10-1 )
36535 {
36536 xoffset = xoff;
36537 yoffset = 56; //should this be -56?
36538 }
36539 else
36540 {
36541 xoffset = 0;
36542 yoffset = 0;
36543 }
36544
36545 int32_t yv = ri->d[rINDEX2]/10000 + yoffset;
36546 int32_t ret = getpixel(bitty, ri->d[rINDEX]/10000, yv); //This is a palette index value.
36547 if(!get_qr(qr_BROKEN_GETPIXEL_VALUE))
36548 ret *= 10000;
36549 return ret;
36550 }
36551
36552 void FFScript::do_bmpcollision()
36553 {
36554 int32_t bmpref = SH::read_stack(ri->sp + 5);
36555 int32_t maskbmpref = SH::read_stack(ri->sp + 4);
36556 int32_t x = SH::read_stack(ri->sp + 3) / 10000;
36557 int32_t y = SH::read_stack(ri->sp + 2) / 10000;
36558 int32_t checkCol = SH::read_stack(ri->sp + 1) / 10000;
36559 int32_t maskCol = SH::read_stack(ri->sp + 0) / 10000;
36560 BITMAP *checkbit = FFCore.GetScriptBitmap(bmpref-10, true);
36561 BITMAP *maskbit = FFCore.GetScriptBitmap(maskbmpref-10, true);
36562 if(!(checkbit && maskbit))
36563 {
36564 set_register(sarg1, -10000);
36565 char buf1[16];
36566 char buf2[16];
36567 zc_itoa(bmpref, buf1);
36568 zc_itoa(maskbmpref, buf2);
36569 Z_scripterrlog("Invalid bitmap%s passed to 'bitmap->CountColor()': %s%s%s\n",
36570 (checkbit || maskbit) ? "" : "s", checkbit ? "" : buf1,
36571 (checkbit || maskbit) ? "" : ", ", maskbit ? "" : buf2);
36572 return;
36573 }
36574 int32_t ret = countColor(checkbit, maskbit, x, y, checkCol, maskCol);
36575 set_register(sarg1, ret*10000);
36576 }
36577
36578
36579 6509791 int32_t FFScript::loadMapData()
36580 {
36581 6509791 int32_t _map = (ri->d[rINDEX] / 10000);
36582 6509791 int32_t _scr = (ri->d[rINDEX2]/10000);
36583
2/2
✓ Branch 0 taken 6420732 times.
✓ Branch 1 taken 89059 times.
6509791 int32_t indx = (zc_max((_map)-1,0) * MAPSCRS + _scr);
36584 //zprint("LoadMapData Map Value: %d\n", _map);
36585 //zprint("LoadMapData Screen Value: %d\n", _scr);
36586 //zprint("LoadMapData Indx Value: %d\n", indx);
36587
2/4
✓ Branch 0 taken 6509791 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6509791 times.
6509791 if ( _map < 1 || _map > map_count )
36588 {
36589 Z_scripterrlog("Invalid Map ID passed to Game->LoadMapData: %d\n", _map);
36590 ri->mapsref = MAX_SIGNED_32;
36591 }
36592
2/4
✓ Branch 0 taken 6509791 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6509791 times.
6509791 else if ( _scr < 0 || _scr > 129 ) //0x00 to 0x81 -Z
36593 {
36594 Z_scripterrlog("Invalid Screen ID passed to Game->LoadMapData: %d\n", _scr);
36595 ri->mapsref = MAX_SIGNED_32;
36596 }
36597 6509791 else ri->mapsref = indx;
36598 //zprint("LoadMapData Screen set ri->mapsref to: %d\n", ri->mapsref);
36599 6509791 return ri->mapsref;
36600 }
36601
36602
36603 // Called when leaving a screen; deallocate arrays created by FFCs that aren't carried over
36604 6979847 void FFScript::deallocateZScriptArray(const int32_t ptrval)
36605 {
36606
1/2
✓ Branch 0 taken 6979847 times.
✗ Branch 1 not taken.
6979847 if(ptrval == 0) return;
36607
2/4
✓ Branch 0 taken 6979847 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6979847 times.
6979847 if(ptrval==0 || ptrval >= NUM_ZSCRIPT_ARRAYS)
36608 Z_scripterrlog("Script tried to deallocate memory at invalid address %ld\n", ptrval);
36609
1/2
✓ Branch 0 taken 6979847 times.
✗ Branch 1 not taken.
6979847 else if(ptrval<0)
36610 Z_scripterrlog("Script tried to deallocate memory at object-based address %ld\n", ptrval);
36611 else
36612 {
36613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6979847 times.
6979847 if(arrayOwner[ptrval].specOwned) return; //ignore this deallocation
36614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6979847 times.
6979847 if(arrayOwner[ptrval].specCleared) return;
36615 6979847 arrayOwner[ptrval].clear();
36616
36617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6979847 times.
6979847 if(localRAM[ptrval].Size() == 0)
36618 Z_scripterrlog("Script tried to deallocate memory that was not allocated at address %ld\n", ptrval);
36619 else
36620 {
36621 6979847 word size = localRAM[ptrval].Size();
36622 6979847 localRAM[ptrval].Clear();
36623
36624 // If this happens once per frame, it can drown out every other message. -L
36625 //Z_eventlog("Deallocated local array with address %ld, size %d\n", ptrval, size);
36626 6979847 size = size;
36627 }
36628 }
36629 6979847 }
36630
36631 433275 int32_t FFScript::get_screen_d(int32_t index1, int32_t index2)
36632 {
36633
3/4
✓ Branch 0 taken 433275 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 433272 times.
433275 if(index2 < 0 || index2 > 7)
36634 {
36635 3 Z_scripterrlog("You were trying to reference an out-of-bounds array index for a screen's D[] array (%ld); valid indices are from 0 to 7.\n", index1);
36636 3 return 0;
36637 }
36638
36639 433272 return game->screen_d[index1][index2];
36640 433275 }
36641
36642 42105 void FFScript::set_screen_d(int32_t index1, int32_t index2, int32_t val)
36643 {
36644
2/4
✓ Branch 0 taken 42105 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 42105 times.
42105 if(index2 < 0 || index2 > 7)
36645 {
36646 Z_scripterrlog("You were trying to reference an out-of-bounds array index for a screen's D[] array (%ld); valid indices are from 0 to 7.\n", index1);
36647 return;
36648 }
36649
36650 42105 game->screen_d[index1][index2] = val;
36651 42105 }
36652
36653 // If scr is currently being used as a layer, return that layer no.
36654 int32_t FFScript::whichlayer(int32_t scr)
36655 {
36656 for(int32_t i = 0; i < 6; i++)
36657 {
36658 if(scr == (tmpscr->layermap[i] - 1) * MAPSCRS + tmpscr->layerscreen[i])
36659 return i;
36660 }
36661
36662 return -1;
36663 }
36664
36665 void FFScript::do_zapout()
36666 {
36667 zapout();
36668 }
36669
36670 void FFScript::do_zapin(){ zapin(); }
36671
36672 void FFScript::do_openscreen() { openscreen(); }
36673 void FFScript::do_closescreen() { closescreen(); }
36674 void FFScript::do_openscreenshape()
36675 {
36676 int32_t shape = get_register(sarg1) / 10000;
36677 if(shape < 0 || shape >= bosMAX)
36678 {
36679 Z_scripterrlog("Invalid shape passed to %s! Valid range %d to %d. Using 'Circle' shape.\n", "Screen->OpeningWipe(int32_t)", 0, bosMAX-1);
36680 shape = bosCIRCLE;
36681 }
36682 openscreen(shape);
36683 }
36684 void FFScript::do_closescreenshape()
36685 {
36686 int32_t shape = get_register(sarg1) / 10000;
36687 if(shape < 0 || shape >= bosMAX)
36688 {
36689 Z_scripterrlog("Invalid shape passed to %s! Valid range %d to %d. Using 'Circle' shape.\n", "Screen->ClosingWipe(int32_t)", 0, bosMAX-1);
36690 shape = bosCIRCLE;
36691 }
36692 closescreen(shape);
36693 }
36694 void FFScript::do_wavyin() { wavyin(); }
36695 void FFScript::do_wavyout() { wavyout(false); }
36696
36697
36698 void FFScript::do_triggersecret(const bool v)
36699 {
36700 int32_t ID = vbound((SH::get_arg(sarg1, v) / 10000), 0, 255);
36701 mapscr *s = tmpscr;
36702 int32_t ft=0, checkflag; //Flag trigger, checked flag temp.
36703 bool putit = true; //Is set false with a mismatch (illegal value input).
36704 //Convert a flag type to a secret type. -Z
36705 switch(ID)
36706 {
36707 case mfANYFIRE:
36708 ft=sBCANDLE;
36709 break;
36710
36711 case mfSTRONGFIRE:
36712 ft=sRCANDLE;
36713 break;
36714
36715 case mfMAGICFIRE:
36716 ft=sWANDFIRE;
36717 break;
36718
36719 case mfDIVINEFIRE:
36720 ft=sDIVINEFIRE;
36721 break;
36722
36723 case mfARROW:
36724 ft=sARROW;
36725 break;
36726
36727 case mfSARROW:
36728 ft=sSARROW;
36729 break;
36730
36731 case mfGARROW:
36732 ft=sGARROW;
36733 break;
36734
36735 case mfSBOMB:
36736 ft=sSBOMB;
36737 break;
36738
36739 case mfBOMB:
36740 ft=sBOMB;
36741 break;
36742
36743 case mfBRANG:
36744 ft=sBRANG;
36745 break;
36746
36747 case mfMBRANG:
36748 ft=sMBRANG;
36749 break;
36750
36751 case mfFBRANG:
36752 ft=sFBRANG;
36753 break;
36754
36755 case mfWANDMAGIC:
36756 ft=sWANDMAGIC;
36757 break;
36758
36759 case mfREFMAGIC:
36760 ft=sREFMAGIC;
36761 break;
36762
36763 case mfREFFIREBALL:
36764 ft=sREFFIREBALL;
36765 break;
36766
36767 case mfSWORD:
36768 ft=sSWORD;
36769 break;
36770
36771 case mfWSWORD:
36772 ft=sWSWORD;
36773 break;
36774
36775 case mfMSWORD:
36776 ft=sMSWORD;
36777 break;
36778
36779 case mfXSWORD:
36780 ft=sXSWORD;
36781 break;
36782
36783 case mfSWORDBEAM:
36784 ft=sSWORDBEAM;
36785 break;
36786
36787 case mfWSWORDBEAM:
36788 ft=sWSWORDBEAM;
36789 break;
36790
36791 case mfMSWORDBEAM:
36792 ft=sMSWORDBEAM;
36793 break;
36794
36795 case mfXSWORDBEAM:
36796 ft=sXSWORDBEAM;
36797 break;
36798
36799 case mfHOOKSHOT:
36800 ft=sHOOKSHOT;
36801 break;
36802
36803 case mfWAND:
36804 ft=sWAND;
36805 break;
36806
36807 case mfHAMMER:
36808 ft=sHAMMER;
36809 break;
36810
36811 case mfSTRIKE:
36812 ft=sSTRIKE;
36813 break;
36814
36815 default:
36816 putit = false;
36817 break;
36818 }
36819 if ( putit )
36820 {
36821 for(int32_t iter=0; iter<2; ++iter)
36822 {
36823 for ( int32_t q = 0; q < 176; q++ )
36824 {
36825 if(iter==1) checkflag=s->sflag[q]; //Placed
36826 else checkflag=combobuf[s->data[q]].flag; //Inherent
36827 Z_message("checkflag is: %d\n", checkflag);
36828 al_trace("checkflag is: %d\n", checkflag);
36829
36830 Z_message("ID is: %ld\n", ID);
36831 al_trace("ID is: %d\n", ID);
36832 //cmbx = COMBOX(q);
36833 ////cmby = COMBOY(q);
36834
36835 //Placed flags
36836 if ( iter == 1 )
36837 {
36838 if ( s->sflag[q] == ID ) {
36839 screen_combo_modify_preroutine(s,q);
36840 s->data[q] = s->secretcombo[ft];
36841 s->cset[q] = s->secretcset[ft];
36842 s->sflag[q] = s->secretflag[ft];
36843 // newflag = s->secretflag[ft];
36844 screen_combo_modify_postroutine(s,q);
36845 }
36846 }
36847 //Inherent flags
36848 else
36849 {
36850 if ( combobuf[s->data[q]].flag == ID ) {
36851 screen_combo_modify_preroutine(s,q);
36852 s->data[q] = s->secretcombo[ft];
36853 s->cset[q] = s->secretcset[ft];
36854 //s->sflag[q] = s->secretflag[ft];
36855 screen_combo_modify_postroutine(s,q);
36856 }
36857
36858 }
36859 }
36860 }
36861 }
36862
36863 }
36864 //NPCData
36865
36866 //NPCData Getter Macros
36867
36868
36869
36870
36871 //NPCData-> Function
36872 #define GET_NPCDATA_FUNCTION_VAR_INT(member) \
36873 { \
36874 int32_t ID = get_register(sarg2) / 10000; \
36875 if(ID < 1 || ID > (MAXGUYS-1)) \
36876 set_register(sarg1, -10000); \
36877 else \
36878 set_register(sarg1, guysbuf[ID].member * 10000); \
36879 }
36880
36881 #define GET_NPCDATA_FUNCTION_VAR_INDEX(member, indexbound) \
36882 { \
36883 int32_t ID = int32_t(ri->d[rINDEX] / 10000);\
36884 int32_t indx = vbound((ri->d[rINDEX2] / 10000), 0, indexbound); \
36885 if(ID < 1 || ID > (MAXGUYS-1)) \
36886 set_register(sarg1, -10000); \
36887 else \
36888 set_register(sarg1, guysbuf[ID].member[indx] * 10000); \
36889 }
36890
36891 #define GET_NPCDATA_FUNCTION_VAR_FLAG(member) \
36892 { \
36893 int32_t ID = int32_t(ri->d[rINDEX] / 10000);\
36894 int32_t flag = int32_t(ri->d[rINDEX2] / 10000);\
36895 if(ID < 1 || ID > (MAXGUYS-1)) \
36896 set_register(sarg1, -10000); \
36897 else \
36898 set_register(sarg1, (guysbuf[ID].member&flag) ? 10000 : 0); \
36899 }
36900
36901 void FFScript::getNPCData_tile(){ GET_NPCDATA_FUNCTION_VAR_INT(tile); } //word
36902 void FFScript::getNPCData_e_height(){ GET_NPCDATA_FUNCTION_VAR_INT(e_height); }
36903 void FFScript::getNPCData_flags(){ GET_NPCDATA_FUNCTION_VAR_INT(flags); } //word
36904 void FFScript::getNPCData_flags2(){ GET_NPCDATA_FUNCTION_VAR_INT(flags2); }
36905 void FFScript::getNPCData_width(){ GET_NPCDATA_FUNCTION_VAR_INT(width); }
36906 void FFScript::getNPCData_height(){ GET_NPCDATA_FUNCTION_VAR_INT(height); }
36907 void FFScript::getNPCData_s_tile(){ GET_NPCDATA_FUNCTION_VAR_INT(s_tile); }
36908 void FFScript::getNPCData_s_width(){ GET_NPCDATA_FUNCTION_VAR_INT(s_width); }
36909 void FFScript::getNPCData_s_height(){ GET_NPCDATA_FUNCTION_VAR_INT(s_height); }
36910 void FFScript::getNPCData_e_tile(){ GET_NPCDATA_FUNCTION_VAR_INT(e_tile); }
36911 void FFScript::getNPCData_e_width(){ GET_NPCDATA_FUNCTION_VAR_INT(e_width); }
36912 void FFScript::getNPCData_hp(){ GET_NPCDATA_FUNCTION_VAR_INT(hp); }
36913 void FFScript::getNPCData_family(){ GET_NPCDATA_FUNCTION_VAR_INT(family); }
36914 void FFScript::getNPCData_cset(){ GET_NPCDATA_FUNCTION_VAR_INT(cset); }
36915 void FFScript::getNPCData_anim(){ GET_NPCDATA_FUNCTION_VAR_INT(anim); }
36916 void FFScript::getNPCData_e_anim(){ GET_NPCDATA_FUNCTION_VAR_INT(e_anim); }
36917 void FFScript::getNPCData_frate(){ GET_NPCDATA_FUNCTION_VAR_INT(frate); }
36918 void FFScript::getNPCData_e_frate(){ GET_NPCDATA_FUNCTION_VAR_INT(e_frate); }
36919 void FFScript::getNPCData_dp(){ GET_NPCDATA_FUNCTION_VAR_INT(dp); }
36920 void FFScript::getNPCData_wdp(){ GET_NPCDATA_FUNCTION_VAR_INT(wdp); }
36921 void FFScript::getNPCData_weapon(){ GET_NPCDATA_FUNCTION_VAR_INT(weapon); }
36922 void FFScript::getNPCData_rate(){ GET_NPCDATA_FUNCTION_VAR_INT(rate); }
36923 void FFScript::getNPCData_hrate(){ GET_NPCDATA_FUNCTION_VAR_INT(hrate); }
36924 void FFScript::getNPCData_step(){ GET_NPCDATA_FUNCTION_VAR_INT(step); }
36925 void FFScript::getNPCData_homing(){ GET_NPCDATA_FUNCTION_VAR_INT(homing); }
36926 void FFScript::getNPCData_grumble(){ GET_NPCDATA_FUNCTION_VAR_INT(grumble); }
36927 void FFScript::getNPCData_item_set(){ GET_NPCDATA_FUNCTION_VAR_INT(item_set); }
36928 void FFScript::getNPCData_bgsfx(){ GET_NPCDATA_FUNCTION_VAR_INT(bgsfx); }
36929 void FFScript::getNPCData_hitsfx(){ GET_NPCDATA_FUNCTION_VAR_INT(hitsfx); }
36930 void FFScript::getNPCData_deadsfx(){ GET_NPCDATA_FUNCTION_VAR_INT(deadsfx); }
36931 void FFScript::getNPCData_xofs(){ GET_NPCDATA_FUNCTION_VAR_INT(xofs); }
36932 void FFScript::getNPCData_yofs(){ GET_NPCDATA_FUNCTION_VAR_INT(yofs); }
36933 void FFScript::getNPCData_zofs(){ GET_NPCDATA_FUNCTION_VAR_INT(zofs); }
36934 void FFScript::getNPCData_hxofs(){ GET_NPCDATA_FUNCTION_VAR_INT(hxofs); }
36935 void FFScript::getNPCData_hyofs(){ GET_NPCDATA_FUNCTION_VAR_INT(hyofs); }
36936 void FFScript::getNPCData_hxsz(){ GET_NPCDATA_FUNCTION_VAR_INT(hxsz); }
36937 void FFScript::getNPCData_hysz(){ GET_NPCDATA_FUNCTION_VAR_INT(hysz); }
36938 void FFScript::getNPCData_hzsz(){ GET_NPCDATA_FUNCTION_VAR_INT(hzsz); }
36939 void FFScript::getNPCData_txsz(){ GET_NPCDATA_FUNCTION_VAR_INT(txsz); }
36940 void FFScript::getNPCData_tysz(){ GET_NPCDATA_FUNCTION_VAR_INT(tysz); }
36941 void FFScript::getNPCData_wpnsprite(){ GET_NPCDATA_FUNCTION_VAR_INT(wpnsprite); }
36942
36943 //NPCData Getters, two inputs, one return, similar to ISSolid
36944
36945 /*
36946
36947 void do_issolid()
36948 {
36949 int32_t x = int32_t(ri->d[rINDEX] / 10000);
36950 int32_t y = int32_t(ri->d[rINDEX2] / 10000);
36951
36952 set_register(sarg1, (_walkflag(x, y, 1) ? 10000 : 0));
36953 }
36954
36955 */
36956
36957
36958
36959
36960
36961
36962 //void FFScript::getNPCData_scriptdefence(){GET_NPCDATA_FUNCTION_VAR_INDEX(scriptdefence)};
36963
36964
36965 void FFScript::getNPCData_defense(){GET_NPCDATA_FUNCTION_VAR_INDEX(defense,int32_t(edefLAST255))};
36966
36967
36968 void FFScript::getNPCData_SIZEflags(){GET_NPCDATA_FUNCTION_VAR_FLAG(SIZEflags);}
36969
36970
36971 void FFScript::getNPCData_misc()
36972 {
36973 int32_t ID = int32_t(ri->d[rINDEX] / 10000); //the enemy ID value
36974 int32_t indx = int32_t(ri->d[rINDEX2] / 10000); //the misc index ID
36975 if ((ID < 1 || ID > 511) || ( indx < 0 || indx > 15 ))
36976 set_register(sarg1, -10000);
36977 switch ( indx )
36978 {
36979 case 0: set_register(sarg1, guysbuf[ID].misc1 * 10000); break;
36980 case 1: set_register(sarg1, guysbuf[ID].misc2 * 10000); break;
36981 case 2: set_register(sarg1, guysbuf[ID].misc3 * 10000); break;
36982 case 3: set_register(sarg1, guysbuf[ID].misc4 * 10000); break;
36983 case 4: set_register(sarg1, guysbuf[ID].misc5 * 10000); break;
36984 case 5: set_register(sarg1, guysbuf[ID].misc6 * 10000); break;
36985 case 6: set_register(sarg1, guysbuf[ID].misc7 * 10000); break;
36986 case 7: set_register(sarg1, guysbuf[ID].misc8 * 10000); break;
36987 case 8: set_register(sarg1, guysbuf[ID].misc9 * 10000); break;
36988 case 9: set_register(sarg1, guysbuf[ID].misc10 * 10000); break;
36989 case 10: set_register(sarg1, guysbuf[ID].misc11 * 10000); break;
36990 case 11: set_register(sarg1, guysbuf[ID].misc12 * 10000); break;
36991 case 12: set_register(sarg1, guysbuf[ID].misc13 * 10000); break;
36992 case 13: set_register(sarg1, guysbuf[ID].misc14 * 10000); break;
36993 case 14: set_register(sarg1, guysbuf[ID].misc15 * 10000); break;
36994 default: set_register(sarg1, -10000); break;
36995 }
36996 }
36997
36998 //NPCData Setters, two inputs, no return; similar to void GetDMapIntro(int32_t DMap, int32_t buffer[]);
36999
37000 /*
37001
37002 void do_getdmapintro(const bool v)
37003 {
37004 int32_t ID = SH::get_arg(sarg1, v) / 10000;
37005 int32_t arrayptr = get_register(sarg2) / 10000;
37006
37007 if(BC::checkDMapID(ID, "Game->GetDMapIntro") != SH::_NoError)
37008 return;
37009
37010 if(ArrayH::setArray(arrayptr, string(DMaps[ID].intro)) == SH::_Overflow)
37011 Z_scripterrlog("Array supplied to 'Game->GetDMapIntro' not large enough\n");
37012 }
37013
37014 */
37015
37016 //NPCData Setter Macros
37017
37018 //Variables for spritedata sp->member
37019
37020
37021
37022 //Functions for NPCData->
37023
37024 #define SET_NPCDATA_FUNCTION_VAR_INT(member, bound) \
37025 { \
37026 int32_t ID = get_register(sarg1) / 10000; \
37027 int32_t val = get_register(sarg2) / 10000; \
37028 if(ID < 1 || ID > (MAXGUYS-1)) \
37029 set_register(sarg1, -10000); \
37030 else \
37031 guysbuf[ID].member = vbound(val,0,bound); \
37032 }
37033
37034
37035
37036 #define SET_NPCDATA_FUNCTION_VAR_INT_NOBOUND(member) \
37037 { \
37038 int32_t ID = get_register(sarg1) / 10000; \
37039 int32_t val = get_register(sarg2) / 10000; \
37040 if(ID < 1 || ID > (MAXGUYS-1)) \
37041 set_register(sarg1, -10000); \
37042 else \
37043 guysbuf[ID].member = val; \
37044 }
37045
37046
37047 //SET_NPC_VAR_INDEX(member,value)
37048 #define SET_NPCDATA_FUNCTION_VAR_INDEX(member, val, bound, indexbound) \
37049 { \
37050 int32_t ID = (ri->d[rINDEX]/10000); \
37051 int32_t indx = vbound((ri->d[rINDEX2]/10000),0,indexbound); \
37052 if(ID < 1 || ID > (MAXGUYS-1)) \
37053 return; \
37054 else \
37055 guysbuf[ID].member[indx] = vbound(val,0,bound); \
37056 }
37057
37058 //Special case for flags, three inputs one return
37059 #define SET_NPCDATA_FUNCTION_VAR_FLAG(member, val) \
37060 { \
37061 int32_t ID = (ri->d[rINDEX]/10000); \
37062 int32_t flag = (ri->d[rINDEX2]/10000); \
37063 if(ID < 1 || ID > (MAXGUYS-1)) \
37064 return; \
37065 else \
37066 { \
37067 if ( val != 0 ) guysbuf[ID].member|=flag; \
37068 else guysbuf[ID].member|= ~flag; \
37069 }\
37070 }
37071
37072 void FFScript::setNPCData_flags(){SET_NPCDATA_FUNCTION_VAR_INT(flags,ZS_DWORD);} //word
37073 void FFScript::setNPCData_flags2(){SET_NPCDATA_FUNCTION_VAR_INT(flags2,ZS_DWORD);}
37074 void FFScript::setNPCData_width(){SET_NPCDATA_FUNCTION_VAR_INT(width,ZS_BYTE);}
37075 void FFScript::setNPCData_tile(){SET_NPCDATA_FUNCTION_VAR_INT(tile,ZS_WORD);}
37076 void FFScript::setNPCData_e_height(){SET_NPCDATA_FUNCTION_VAR_INT(e_height,ZS_BYTE);}
37077 void FFScript::setNPCData_height(){SET_NPCDATA_FUNCTION_VAR_INT(height,ZS_BYTE);}
37078 void FFScript::setNPCData_s_tile(){SET_NPCDATA_FUNCTION_VAR_INT(s_tile,ZS_WORD);}
37079 void FFScript::setNPCData_s_width(){SET_NPCDATA_FUNCTION_VAR_INT(s_width,ZS_BYTE);}
37080 void FFScript::setNPCData_s_height(){SET_NPCDATA_FUNCTION_VAR_INT(s_height,ZS_BYTE);}
37081 void FFScript::setNPCData_e_tile(){SET_NPCDATA_FUNCTION_VAR_INT(e_tile,ZS_WORD);}
37082 void FFScript::setNPCData_e_width(){SET_NPCDATA_FUNCTION_VAR_INT(e_width,ZS_BYTE);}
37083 void FFScript::setNPCData_hp(){SET_NPCDATA_FUNCTION_VAR_INT(hp,ZS_SHORT);}
37084 void FFScript::setNPCData_family(){SET_NPCDATA_FUNCTION_VAR_INT(family,ZS_SHORT);}
37085 void FFScript::setNPCData_cset(){SET_NPCDATA_FUNCTION_VAR_INT(cset,ZS_SHORT);}
37086 void FFScript::setNPCData_anim(){SET_NPCDATA_FUNCTION_VAR_INT(anim,ZS_SHORT);}
37087 void FFScript::setNPCData_e_anim(){SET_NPCDATA_FUNCTION_VAR_INT(e_anim,ZS_SHORT);}
37088 void FFScript::setNPCData_frate(){SET_NPCDATA_FUNCTION_VAR_INT(frate,ZS_SHORT);}
37089 void FFScript::setNPCData_e_frate(){SET_NPCDATA_FUNCTION_VAR_INT(e_frate,ZS_SHORT);}
37090 void FFScript::setNPCData_dp(){SET_NPCDATA_FUNCTION_VAR_INT(dp,ZS_SHORT);}
37091 void FFScript::setNPCData_wdp(){SET_NPCDATA_FUNCTION_VAR_INT(wdp,ZS_SHORT);}
37092 void FFScript::setNPCData_weapon(){SET_NPCDATA_FUNCTION_VAR_INT(weapon,ZS_SHORT);}
37093 void FFScript::setNPCData_rate(){SET_NPCDATA_FUNCTION_VAR_INT(rate,ZS_SHORT);}
37094 void FFScript::setNPCData_hrate(){SET_NPCDATA_FUNCTION_VAR_INT(hrate,ZS_SHORT);}
37095 void FFScript::setNPCData_step(){SET_NPCDATA_FUNCTION_VAR_INT(step,ZS_SHORT);}
37096 void FFScript::setNPCData_homing(){SET_NPCDATA_FUNCTION_VAR_INT(homing,ZS_SHORT);}
37097 void FFScript::setNPCData_grumble(){SET_NPCDATA_FUNCTION_VAR_INT(grumble,ZS_SHORT);}
37098 void FFScript::setNPCData_item_set(){SET_NPCDATA_FUNCTION_VAR_INT(item_set,ZS_SHORT);}
37099 void FFScript::setNPCData_bgsfx(){SET_NPCDATA_FUNCTION_VAR_INT(bgsfx,ZS_SHORT);}
37100 void FFScript::setNPCData_hitsfx(){SET_NPCDATA_FUNCTION_VAR_INT(hitsfx,ZS_BYTE);}
37101 void FFScript::setNPCData_deadsfx(){SET_NPCDATA_FUNCTION_VAR_INT(deadsfx,ZS_BYTE);}
37102 void FFScript::setNPCData_xofs(){SET_NPCDATA_FUNCTION_VAR_INT_NOBOUND(xofs);}
37103 void FFScript::setNPCData_yofs(){SET_NPCDATA_FUNCTION_VAR_INT_NOBOUND(yofs);}
37104 void FFScript::setNPCData_zofs(){SET_NPCDATA_FUNCTION_VAR_INT_NOBOUND(zofs);}
37105 void FFScript::setNPCData_hxofs(){SET_NPCDATA_FUNCTION_VAR_INT_NOBOUND(hxofs);}
37106 void FFScript::setNPCData_hyofs(){SET_NPCDATA_FUNCTION_VAR_INT_NOBOUND(hyofs);}
37107 void FFScript::setNPCData_hxsz(){SET_NPCDATA_FUNCTION_VAR_INT_NOBOUND(hxsz);}
37108 void FFScript::setNPCData_hysz(){SET_NPCDATA_FUNCTION_VAR_INT_NOBOUND(hysz);}
37109 void FFScript::setNPCData_hzsz(){SET_NPCDATA_FUNCTION_VAR_INT_NOBOUND(hzsz);}
37110 void FFScript::setNPCData_txsz(){SET_NPCDATA_FUNCTION_VAR_INT_NOBOUND(txsz);}
37111 void FFScript::setNPCData_tysz(){SET_NPCDATA_FUNCTION_VAR_INT_NOBOUND(tysz);}
37112 void FFScript::setNPCData_wpnsprite(){SET_NPCDATA_FUNCTION_VAR_INT(wpnsprite,511);}
37113
37114 //NPCData Setters, three inputs, no return. works as SetDMapScreenD function
37115
37116
37117
37118
37119
37120
37121
37122 //void FFScript::setNPCData_scriptdefence(){SET_NPCDATA_FUNCTION_VAR_INDEX(scriptdefence);}
37123 void FFScript::setNPCData_defense(int32_t v){SET_NPCDATA_FUNCTION_VAR_INDEX(defense,v, ZS_INT, int32_t(edefLAST255) );}
37124 void FFScript::setNPCData_SIZEflags(int32_t v){SET_NPCDATA_FUNCTION_VAR_FLAG(SIZEflags,v);}
37125 void FFScript::setNPCData_misc(int32_t val)
37126 {
37127 int32_t ID = int32_t(ri->d[rINDEX] / 10000); //the enemy ID value
37128 int32_t indx = int32_t(ri->d[rINDEX2] / 10000); //the misc index ID
37129 if ((ID < 1 || ID > 511) || ( indx < 0 || indx > 15 )) return;
37130 switch ( indx )
37131 {
37132 case 0: guysbuf[ID].misc1 = val; break;
37133 case 1: guysbuf[ID].misc2 = val; break;
37134 case 2: guysbuf[ID].misc3 = val; break;
37135 case 3: guysbuf[ID].misc4 = val; break;
37136 case 4: guysbuf[ID].misc5 = val; break;
37137 case 5: guysbuf[ID].misc6 = val; break;
37138 case 6: guysbuf[ID].misc7 = val; break;
37139 case 7: guysbuf[ID].misc8 = val; break;
37140 case 8: guysbuf[ID].misc9 = val; break;
37141 case 9: guysbuf[ID].misc10 = val; break;
37142 case 10: guysbuf[ID].misc11 = val; break;
37143 case 11: guysbuf[ID].misc12 = val; break;
37144 case 12: guysbuf[ID].misc13 = val; break;
37145 case 13: guysbuf[ID].misc14 = val; break;
37146 case 14: guysbuf[ID].misc15 = val; break;
37147 default: break;
37148 }
37149
37150 };
37151
37152 //ComboData
37153
37154 //Macros
37155
37156 //Are these right? newcombo is *combo_class_buf and the others are *combobuf
37157
37158 //Getters for ComboData 'Type' submembers.
37159 #define GET_COMBODATA_TYPE_INT(member) \
37160 { \
37161 int32_t ID = vbound((get_register(sarg2) / 10000),0,MAXCOMBOS);\
37162 set_register(sarg1, combo_class_buf[combobuf[ID].type].member * 10000); \
37163 }
37164
37165 //this may need additional macros.
37166 //for combo_class_buf[ID].member ?
37167 //I'm not sure which it needs to be at present.
37168
37169 #define GET_COMBODATA_TYPE_INDEX(member, bound) \
37170 { \
37171 int32_t ID = int32_t(vbound((ri->d[rINDEX] / 10000),0,MAXCOMBOS));\
37172 int32_t indx = int32_t(vbound((ri->d[rINDEX2] / 10000), 0, bound));\
37173 set_register(sarg1, combo_class_buf[combobuf[ID].type].member[indx] * 10000); \
37174 }
37175
37176 #define GET_COMBODATA_TYPE_FLAG(member) \
37177 { \
37178 int32_t ID = int32_t(vbound(ri->d[rINDEX] / 10000),0,MAXCOMBOS);\
37179 int32_t flag = int32_t(ri->d[rINDEX2] / 10000);\
37180 set_register(sarg1, (combo_class_buf[combobuf[ID].type].member&flag) ? 10000 : 0); \
37181 }
37182
37183
37184
37185 //Getters for ComboData main members.
37186 #define GET_COMBODATA_VAR_INT(member) \
37187 { \
37188 int32_t ID = vbound( (get_register(sarg2) / 10000), 0, MAXCOMBOS);\
37189 set_register(sarg1, combobuf[ID].member * 10000); \
37190 }
37191
37192 #define GET_COMBODATA_VAR_INDEX(member, bound) \
37193 { \
37194 int32_t ID = int32_t( vbound( (ri->d[rINDEX] / 10000),0,MAXCOMBOS) );\
37195 int32_t indx = int32_t ( vbound( (ri->d[rINDEX2] / 10000),0,bound) );\
37196 set_register(sarg1, combobuf[ID].member[indx] * 10000); \
37197 }
37198
37199 #define GET_COMBODATA_VAR_FLAG(member) \
37200 { \
37201 int32_t ID = int32_t( vbound( ( ri->d[rINDEX] / 10000),0,MAXCOMBOS) );\
37202 int32_t flag = int32_t(ri->d[rINDEX2] / 10000);\
37203 set_register(sarg1, (combobuf[ID].member&flag) ? 10000 : 0); \
37204 }
37205
37206
37207
37208 //ComboData Setter Macros
37209
37210 //Setters for ComboData 'type' submembers.
37211 #define SET_COMBODATA_TYPE_INT(member, bound) \
37212 { \
37213 int32_t ID = get_register(sarg1) / 10000; \
37214 int32_t val = vbound( (get_register(sarg2) / 10000), 0, bound); \
37215 if(ID < 1 || ID > 511) \
37216 set_register(sarg1, -10000); \
37217 else \
37218 combo_class_buf[combobuf[ID].type].member = val; \
37219 }
37220
37221 #define SET_COMBODATA_TYPE_INDEX(member, val, bound, indexbound) \
37222 { \
37223 int32_t ID = vbound((ri->d[rINDEX]/10000),0,MAXCOMBOS); \
37224 int32_t indx = vbound((ri->d[rINDEX2]/10000),0,indexbound); \
37225 combo_class_buf[combobuf[ID].type].member[indx] = vbound(val,0,bound); \
37226 }
37227
37228 #define SET_COMBODATA_TYPE_FLAG(member, val, bound) \
37229 { \
37230 int32_t ID = vbound((ri->d[rINDEX]/10000),0,MAXCOMBOS); \
37231 int32_t flag = (ri->d[rINDEX2]/10000); \
37232 combo_class_buf[combobuf[ID].type].member&flag = ((vbound(val,0,bound))!=0); \
37233 \
37234
37235
37236 //Setters for ComboData main members
37237 #define SET_COMBODATA_VAR_INT(member, bound) \
37238 { \
37239 int32_t ID = vbound( (get_register(sarg1) / 10000), 0, MAXCOMBOS); \
37240 int32_t val = vbound((get_register(sarg2) / 10000),0,bound); \
37241 combobuf[ID].member = val; \
37242 }
37243
37244 //SET_NPC_VAR_INDEX(member,value)
37245 #define SET_COMBODATA_VAR_INDEX(member, val, bound, indexbound) \
37246 { \
37247 int32_t ID = vbound((ri->d[rINDEX]/10000),0,MAXCOMBOS); \
37248 int32_t indx = vbound((ri->d[rINDEX2]/10000),0,indexbound); \
37249 combobuf[ID].member[indx] = vbound(val,0,bound); \
37250 }
37251
37252 //Special case for flags, three inputs one return
37253 #define SET_COMBODATA_VAR_FLAG(member, val, bound) \
37254 { \
37255 int32_t ID = vbound((ri->d[rINDEX]/10000),0,MAXCOMBOS); \
37256 int32_t flag = (ri->d[rINDEX2]/10000); \
37257 else \
37258 { \
37259 combobuf[ID].member&flag = ((bvound(val,0,bound))!=0); \
37260 }\
37261 }
37262
37263 //Getters
37264
37265 //one input, one return
37266 void FFScript::getComboData_block_enemies(){ GET_COMBODATA_TYPE_INT(block_enemies); } //byte a
37267 void FFScript::getComboData_block_hole(){ GET_COMBODATA_TYPE_INT(block_hole); } //byte b
37268 void FFScript::getComboData_block_trigger(){ GET_COMBODATA_TYPE_INT(block_trigger); } //byte c
37269 void FFScript::getComboData_conveyor_x_speed(){ GET_COMBODATA_TYPE_INT(conveyor_x_speed); } //int16_t e
37270 void FFScript::getComboData_conveyor_y_speed(){ GET_COMBODATA_TYPE_INT(conveyor_y_speed); } //int16_t f
37271 void FFScript::getComboData_create_enemy(){ GET_COMBODATA_TYPE_INT(create_enemy); } //word g
37272 void FFScript::getComboData_create_enemy_when(){ GET_COMBODATA_TYPE_INT(create_enemy_when); } //byte h
37273 void FFScript::getComboData_create_enemy_change(){ GET_COMBODATA_TYPE_INT(create_enemy_change); } //int32_t i
37274 void FFScript::getComboData_directional_change_type(){ GET_COMBODATA_TYPE_INT(directional_change_type); } //byte j
37275 void FFScript::getComboData_distance_change_tiles(){ GET_COMBODATA_TYPE_INT(distance_change_tiles); } //int32_t k
37276 void FFScript::getComboData_dive_item(){ GET_COMBODATA_TYPE_INT(dive_item); } //int16_t l
37277 void FFScript::getComboData_dock(){ GET_COMBODATA_TYPE_INT(dock); } //byte m
37278 void FFScript::getComboData_fairy(){ GET_COMBODATA_TYPE_INT(fairy); } //byte n
37279 void FFScript::getComboData_ff_combo_attr_change(){ GET_COMBODATA_TYPE_INT(ff_combo_attr_change); } //byte o
37280 void FFScript::getComboData_foot_decorations_tile(){ GET_COMBODATA_TYPE_INT(foot_decorations_tile); } //int32_t p
37281 void FFScript::getComboData_foot_decorations_type(){ GET_COMBODATA_TYPE_INT(foot_decorations_type); } //byte q
37282 void FFScript::getComboData_hookshot_grab_point(){ GET_COMBODATA_TYPE_INT(hookshot_grab_point); } //byte r
37283 void FFScript::getComboData_ladder_pass(){ GET_COMBODATA_TYPE_INT(ladder_pass); } //byte s
37284 void FFScript::getComboData_lock_block_type(){ GET_COMBODATA_TYPE_INT(lock_block_type); } //byte t
37285 void FFScript::getComboData_lock_block_change(){ GET_COMBODATA_TYPE_INT(lock_block_change); } //int32_t u
37286 void FFScript::getComboData_magic_mirror_type(){ GET_COMBODATA_TYPE_INT(magic_mirror_type); } //byte v
37287 void FFScript::getComboData_modify_hp_amount(){ GET_COMBODATA_TYPE_INT(modify_hp_amount); } //int16_t w
37288 void FFScript::getComboData_modify_hp_delay(){ GET_COMBODATA_TYPE_INT(modify_hp_delay); } //byte x
37289 void FFScript::getComboData_modify_hp_type(){ GET_COMBODATA_TYPE_INT(modify_hp_type); } //byte y
37290 void FFScript::getComboData_modify_mp_amount(){ GET_COMBODATA_TYPE_INT(modify_mp_amount); } //int16_t z
37291 void FFScript::getComboData_modify_mp_delay(){ GET_COMBODATA_TYPE_INT(modify_mp_delay); } //byte aa
37292 void FFScript::getComboData_modify_mp_type(){ GET_COMBODATA_TYPE_INT(modify_mp_type); } //byte ab
37293 void FFScript::getComboData_no_push_blocks(){ GET_COMBODATA_TYPE_INT(no_push_blocks); } //byte ac
37294 void FFScript::getComboData_overhead(){ GET_COMBODATA_TYPE_INT(overhead); } //byte ad
37295 void FFScript::getComboData_place_enemy(){ GET_COMBODATA_TYPE_INT(place_enemy); } //byte ae
37296 void FFScript::getComboData_push_direction(){ GET_COMBODATA_TYPE_INT(push_direction); } //byte af
37297 void FFScript::getComboData_push_weight(){ GET_COMBODATA_TYPE_INT(push_weight); } //byte ag heavy or not
37298 void FFScript::getComboData_push_wait(){ GET_COMBODATA_TYPE_INT(push_wait); } //byte ah
37299 void FFScript::getComboData_pushed(){ GET_COMBODATA_TYPE_INT(pushed); } //byte ai
37300 void FFScript::getComboData_raft(){ GET_COMBODATA_TYPE_INT(raft); } //byte aj
37301 void FFScript::getComboData_reset_room(){ GET_COMBODATA_TYPE_INT(reset_room); } //byte ak
37302 void FFScript::getComboData_save_point_type(){ GET_COMBODATA_TYPE_INT(save_point_type); } //byte al
37303 void FFScript::getComboData_screen_freeze_type(){ GET_COMBODATA_TYPE_INT(screen_freeze_type); } //byte am
37304
37305 void FFScript::getComboData_secret_combo(){ GET_COMBODATA_TYPE_INT(secret_combo); } //byte an
37306 void FFScript::getComboData_singular(){ GET_COMBODATA_TYPE_INT(singular); } //byte ao
37307 void FFScript::getComboData_slow_movement(){ GET_COMBODATA_TYPE_INT(slow_movement); } //byte ap
37308 void FFScript::getComboData_statue_type(){ GET_COMBODATA_TYPE_INT(statue_type); } //byte aq
37309 void FFScript::getComboData_step_type(){ GET_COMBODATA_TYPE_INT(step_type); } //byte ar
37310 void FFScript::getComboData_step_change_to(){ GET_COMBODATA_TYPE_INT(step_change_to); } //int32_t as
37311 void FFScript::getComboData_strike_remnants(){ GET_COMBODATA_TYPE_INT(strike_remnants); } //int32_t au
37312 void FFScript::getComboData_strike_remnants_type(){ GET_COMBODATA_TYPE_INT(strike_remnants_type); } //byte av
37313 void FFScript::getComboData_strike_change(){ GET_COMBODATA_TYPE_INT(strike_change); } //int32_t aw
37314 void FFScript::getComboData_strike_item(){ GET_COMBODATA_TYPE_INT(strike_item); } //int16_t ax
37315 void FFScript::getComboData_touch_item(){ GET_COMBODATA_TYPE_INT(touch_item); } //int16_t ay
37316 void FFScript::getComboData_touch_stairs(){ GET_COMBODATA_TYPE_INT(touch_stairs); } //byte az
37317 void FFScript::getComboData_trigger_type(){ GET_COMBODATA_TYPE_INT(trigger_type); } //byte ba
37318 void FFScript::getComboData_trigger_sensitive(){ GET_COMBODATA_TYPE_INT(trigger_sensitive); } //byte bb
37319 void FFScript::getComboData_warp_type(){ GET_COMBODATA_TYPE_INT(warp_type); } //byte bc
37320 void FFScript::getComboData_warp_sensitive(){ GET_COMBODATA_TYPE_INT(warp_sensitive); } //byte bd
37321 void FFScript::getComboData_warp_direct(){ GET_COMBODATA_TYPE_INT(warp_direct); } //byte be
37322 void FFScript::getComboData_warp_location(){ GET_COMBODATA_TYPE_INT(warp_location); } //byte bf
37323 void FFScript::getComboData_water(){ GET_COMBODATA_TYPE_INT(water); } //byte bg
37324 void FFScript::getComboData_whistle(){ GET_COMBODATA_TYPE_INT(whistle); } //byte bh
37325 void FFScript::getComboData_win_game(){ GET_COMBODATA_TYPE_INT(win_game); } //byte bi
37326 void FFScript::getComboData_block_weapon_lvl(){ GET_COMBODATA_TYPE_INT(block_weapon_lvl); } //byte bj - max level of weapon to block
37327
37328 void FFScript::getComboData_tile(){ GET_COMBODATA_VAR_INT(tile); } //newcombo, word
37329 void FFScript::getComboData_flip(){ GET_COMBODATA_VAR_INT(flip); } //newcombo byte
37330
37331 void FFScript::getComboData_walk(){ GET_COMBODATA_VAR_INT(walk); } //newcombo byte
37332 void FFScript::getComboData_type(){ GET_COMBODATA_VAR_INT(type); } //newcombo byte
37333 void FFScript::getComboData_csets(){ GET_COMBODATA_VAR_INT(csets); } //newcombo byte
37334 void FFScript::getComboData_frames(){ GET_COMBODATA_VAR_INT(frames); } //newcombo byte
37335 void FFScript::getComboData_speed(){ GET_COMBODATA_VAR_INT(speed); } //newcombo byte
37336 void FFScript::getComboData_nextcombo(){ GET_COMBODATA_VAR_INT(nextcombo); } //newcombo word
37337 void FFScript::getComboData_nextcset(){ GET_COMBODATA_VAR_INT(nextcset); } //newcombo byte
37338 void FFScript::getComboData_flag(){ GET_COMBODATA_VAR_INT(flag); } //newcombo byte
37339 void FFScript::getComboData_skipanim(){ GET_COMBODATA_VAR_INT(skipanim); } //newcombo byte
37340 void FFScript::getComboData_nexttimer(){ GET_COMBODATA_VAR_INT(nexttimer); } //newcombo word
37341 void FFScript::getComboData_skipanimy(){ GET_COMBODATA_VAR_INT(skipanimy); } //newcombo byte
37342 void FFScript::getComboData_animflags(){ GET_COMBODATA_VAR_INT(animflags); } //newcombo byte
37343
37344
37345 //two inputs, one return
37346 void FFScript::getComboData_block_weapon(){ GET_COMBODATA_TYPE_INDEX(block_weapon,32); } //byte array[32] d (ID of LWeapon)
37347 void FFScript::getComboData_expansion(){ GET_COMBODATA_VAR_INDEX(expansion,6); } //newcombo byte, arr[6]
37348 void FFScript::getComboData_strike_weapons(){ GET_COMBODATA_TYPE_INDEX(strike_weapons,32); } //byte at, arr[32]
37349
37350 //Setters, two inputs no returns
37351
37352 void FFScript::setComboData_block_enemies(){ SET_COMBODATA_TYPE_INT(block_enemies,ZS_BYTE); } //byte a
37353 void FFScript::setComboData_block_hole(){ SET_COMBODATA_TYPE_INT(block_hole,ZS_BYTE); } //byte b
37354 void FFScript::setComboData_block_trigger(){ SET_COMBODATA_TYPE_INT(block_trigger,ZS_BYTE); } //byte c
37355 void FFScript::setComboData_conveyor_x_speed(){ SET_COMBODATA_TYPE_INT(conveyor_x_speed,ZS_SHORT); } //int16_t e
37356 void FFScript::setComboData_conveyor_y_speed(){ SET_COMBODATA_TYPE_INT(conveyor_y_speed,ZS_SHORT); } //int16_t f
37357 void FFScript::setComboData_create_enemy(){ SET_COMBODATA_TYPE_INT(create_enemy,ZS_WORD); } //word g
37358 void FFScript::setComboData_create_enemy_when(){ SET_COMBODATA_TYPE_INT(create_enemy_when,ZS_BYTE); } //byte h
37359 void FFScript::setComboData_create_enemy_change(){ SET_COMBODATA_TYPE_INT(create_enemy_change,ZS_LONG); } //int32_t i
37360 void FFScript::setComboData_directional_change_type(){ SET_COMBODATA_TYPE_INT(directional_change_type,ZS_BYTE); } //byte j
37361 void FFScript::setComboData_distance_change_tiles(){ SET_COMBODATA_TYPE_INT(distance_change_tiles,ZS_LONG); } //int32_t k
37362 void FFScript::setComboData_dive_item(){ SET_COMBODATA_TYPE_INT(dive_item,ZS_SHORT); } //int16_t l
37363 void FFScript::setComboData_dock(){ SET_COMBODATA_TYPE_INT(dock,ZS_BYTE); } //byte m
37364 void FFScript::setComboData_fairy(){ SET_COMBODATA_TYPE_INT(fairy,ZS_BYTE); } //byte n
37365 void FFScript::setComboData_ff_combo_attr_change(){ SET_COMBODATA_TYPE_INT(ff_combo_attr_change,ZS_BYTE); } //byte o
37366 void FFScript::setComboData_foot_decorations_tile(){ SET_COMBODATA_TYPE_INT(foot_decorations_tile,ZS_LONG); } //int32_t p
37367 void FFScript::setComboData_foot_decorations_type(){ SET_COMBODATA_TYPE_INT(foot_decorations_type,ZS_BYTE); } //byte q
37368 void FFScript::setComboData_hookshot_grab_point(){ SET_COMBODATA_TYPE_INT(hookshot_grab_point,ZS_BYTE); } //byte r
37369 void FFScript::setComboData_ladder_pass(){ SET_COMBODATA_TYPE_INT(ladder_pass,ZS_BYTE); } //byte s
37370 void FFScript::setComboData_lock_block_type(){ SET_COMBODATA_TYPE_INT(lock_block_type,ZS_BYTE); } //byte t
37371 void FFScript::setComboData_lock_block_change(){ SET_COMBODATA_TYPE_INT(lock_block_change,ZS_LONG); } //int32_t u
37372 void FFScript::setComboData_magic_mirror_type(){ SET_COMBODATA_TYPE_INT(magic_mirror_type,ZS_BYTE); } //byte v
37373 void FFScript::setComboData_modify_hp_amount(){ SET_COMBODATA_TYPE_INT(modify_hp_amount,ZS_SHORT); } //int16_t w
37374 void FFScript::setComboData_modify_hp_delay(){ SET_COMBODATA_TYPE_INT(modify_hp_delay,ZS_BYTE); } //byte x
37375 void FFScript::setComboData_modify_hp_type(){ SET_COMBODATA_TYPE_INT(modify_hp_type,ZS_BYTE); } //byte y
37376 void FFScript::setComboData_modify_mp_amount(){ SET_COMBODATA_TYPE_INT(modify_mp_amount,ZS_SHORT); } //int16_t z
37377 void FFScript::setComboData_modify_mp_delay(){ SET_COMBODATA_TYPE_INT(modify_mp_delay,ZS_BYTE); } //byte aa
37378 void FFScript::setComboData_modify_mp_type(){ SET_COMBODATA_TYPE_INT(modify_mp_type,ZS_BYTE); } //byte ab
37379 void FFScript::setComboData_no_push_blocks(){ SET_COMBODATA_TYPE_INT(no_push_blocks,ZS_BYTE); } //byte ac
37380 void FFScript::setComboData_overhead(){ SET_COMBODATA_TYPE_INT(overhead,ZS_BYTE); } //byte ad
37381 void FFScript::setComboData_place_enemy(){ SET_COMBODATA_TYPE_INT(place_enemy,ZS_BYTE); } //byte ae
37382 void FFScript::setComboData_push_direction(){ SET_COMBODATA_TYPE_INT(push_direction,ZS_BYTE); } //byte af
37383 void FFScript::setComboData_push_weight(){ SET_COMBODATA_TYPE_INT(push_weight,ZS_BYTE); } //byte ag heavy or not
37384 void FFScript::setComboData_push_wait(){ SET_COMBODATA_TYPE_INT(push_wait,ZS_BYTE); } //byte ah
37385 void FFScript::setComboData_pushed(){ SET_COMBODATA_TYPE_INT(pushed,ZS_BYTE); } //byte ai
37386 void FFScript::setComboData_raft(){ SET_COMBODATA_TYPE_INT(raft,ZS_BYTE); } //byte aj
37387 void FFScript::setComboData_reset_room(){ SET_COMBODATA_TYPE_INT(reset_room,ZS_BYTE); } //byte ak
37388 void FFScript::setComboData_save_point_type(){ SET_COMBODATA_TYPE_INT(save_point_type,ZS_BYTE); } //byte al
37389 void FFScript::setComboData_screen_freeze_type(){ SET_COMBODATA_TYPE_INT(screen_freeze_type,ZS_BYTE); } //byte am
37390
37391 void FFScript::setComboData_secret_combo(){ SET_COMBODATA_TYPE_INT(secret_combo,ZS_BYTE); } //byte an
37392 void FFScript::setComboData_singular(){ SET_COMBODATA_TYPE_INT(singular,ZS_BYTE); } //byte ao
37393 void FFScript::setComboData_slow_movement(){ SET_COMBODATA_TYPE_INT(slow_movement,ZS_BYTE); } //byte ap
37394 void FFScript::setComboData_statue_type(){ SET_COMBODATA_TYPE_INT(statue_type,ZS_BYTE); } //byte aq
37395 void FFScript::setComboData_step_type(){ SET_COMBODATA_TYPE_INT(step_type,ZS_BYTE); } //byte ar
37396 void FFScript::setComboData_step_change_to(){ SET_COMBODATA_TYPE_INT(step_change_to,ZS_LONG); } //int32_t as
37397
37398 void FFScript::setComboData_strike_remnants(){ SET_COMBODATA_TYPE_INT(strike_remnants,ZS_LONG); } //int32_t au
37399 void FFScript::setComboData_strike_remnants_type(){ SET_COMBODATA_TYPE_INT(strike_remnants_type,ZS_BYTE); } //byte av
37400 void FFScript::setComboData_strike_change(){ SET_COMBODATA_TYPE_INT(strike_change,ZS_LONG); } //int32_t aw
37401 void FFScript::setComboData_strike_item(){ SET_COMBODATA_TYPE_INT(strike_item,ZS_SHORT); } //int16_t ax
37402 void FFScript::setComboData_touch_item(){ SET_COMBODATA_TYPE_INT(touch_item,ZS_SHORT); } //int16_t ay
37403 void FFScript::setComboData_touch_stairs(){ SET_COMBODATA_TYPE_INT(touch_stairs,ZS_BYTE); } //byte az
37404 void FFScript::setComboData_trigger_type(){ SET_COMBODATA_TYPE_INT(trigger_type,ZS_BYTE); } //byte ba
37405 void FFScript::setComboData_trigger_sensitive(){ SET_COMBODATA_TYPE_INT(trigger_sensitive,ZS_BYTE); } //byte bb
37406 void FFScript::setComboData_warp_type(){ SET_COMBODATA_TYPE_INT(warp_type,ZS_BYTE); } //byte bc
37407 void FFScript::setComboData_warp_sensitive(){ SET_COMBODATA_TYPE_INT(warp_sensitive,ZS_BYTE); } //byte bd
37408 void FFScript::setComboData_warp_direct(){ SET_COMBODATA_TYPE_INT(warp_direct,ZS_BYTE); } //byte be
37409 void FFScript::setComboData_warp_location(){ SET_COMBODATA_TYPE_INT(warp_location,ZS_BYTE); } //byte bf
37410 void FFScript::setComboData_water(){ SET_COMBODATA_TYPE_INT(water,ZS_BYTE); } //byte bg
37411 void FFScript::setComboData_whistle(){ SET_COMBODATA_TYPE_INT(whistle,ZS_BYTE); } //byte bh
37412 void FFScript::setComboData_win_game(){ SET_COMBODATA_TYPE_INT(win_game,ZS_BYTE); } //byte bi
37413 void FFScript::setComboData_block_weapon_lvl(){ SET_COMBODATA_TYPE_INT(block_weapon_lvl,ZS_BYTE); } //byte bj - max level of weapon to block
37414
37415 //combobuf
37416 void FFScript::setComboData_tile(){ SET_COMBODATA_VAR_INT(tile,ZS_WORD); } //newcombo, word
37417 void FFScript::setComboData_flip(){ SET_COMBODATA_VAR_INT(flip,ZS_BYTE); } //newcombo byte
37418
37419 void FFScript::setComboData_walk(){ SET_COMBODATA_VAR_INT(walk,ZS_BYTE); } //newcombo byte
37420 void FFScript::setComboData_type(){ SET_COMBODATA_VAR_INT(type,ZS_BYTE); } //newcombo byte
37421 void FFScript::setComboData_csets(){ SET_COMBODATA_VAR_INT(csets,ZS_BYTE); } //newcombo byte
37422 void FFScript::setComboData_frames(){ SET_COMBODATA_VAR_INT(frames,ZS_BYTE); } //newcombo byte
37423 void FFScript::setComboData_speed(){ SET_COMBODATA_VAR_INT(speed,ZS_BYTE); } //newcombo byte
37424 void FFScript::setComboData_nextcombo(){ SET_COMBODATA_VAR_INT(nextcombo,ZS_WORD); } //newcombo word
37425 void FFScript::setComboData_nextcset(){ SET_COMBODATA_VAR_INT(nextcset,ZS_BYTE); } //newcombo byte
37426 void FFScript::setComboData_flag(){ SET_COMBODATA_VAR_INT(flag,ZS_BYTE); } //newcombo byte
37427 void FFScript::setComboData_skipanim(){ SET_COMBODATA_VAR_INT(skipanim,ZS_BYTE); } //newcombo byte
37428 void FFScript::setComboData_nexttimer(){ SET_COMBODATA_VAR_INT(nexttimer,ZS_WORD); } //newcombo word
37429 void FFScript::setComboData_skipanimy(){ SET_COMBODATA_VAR_INT(skipanimy,ZS_BYTE); } //newcombo byte
37430 void FFScript::setComboData_animflags(){ SET_COMBODATA_VAR_INT(animflags,ZS_BYTE); } //newcombo byte
37431
37432 //three inputs, no returns
37433 void FFScript::setComboData_block_weapon(int32_t v){ SET_COMBODATA_TYPE_INDEX(block_weapon,v,ZS_BYTE,32); } //byte array[32] d (ID of LWeapon)
37434 void FFScript::setComboData_strike_weapons(int32_t v){ SET_COMBODATA_TYPE_INDEX(strike_weapons,v,ZS_BYTE,32); } //byte at, arr[32]
37435 void FFScript::setComboData_expansion(int32_t v){ SET_COMBODATA_VAR_INDEX(expansion,v,ZS_BYTE,6); } //newcombo byte, arr[6]
37436
37437 //SpriteData Macros
37438 #define GET_SPRITEDATA_TYPE_INT(member) \
37439 { \
37440 int32_t ID = vbound((get_register(sarg2) / 10000),0,255);\
37441 set_register(sarg1, wpnsbuf[ID].member * 10000); \
37442 }
37443
37444 #define SET_SPRITEDATA_TYPE_INT(member, bound) \
37445 { \
37446 int32_t ID = get_register(sarg1) / 10000; \
37447 int32_t val = vbound( (get_register(sarg2) / 10000), 0, bound); \
37448 if(ID < 1 || ID > 255) \
37449 set_register(sarg1, -10000); \
37450 else \
37451 wpnsbuf[ID].member = val; \
37452 }
37453
37454 #define SET_SPRITEDATA_TYPE_INT_NOBOUND(member) \
37455 { \
37456 int32_t ID = get_register(sarg1) / 10000; \
37457 int32_t val = get_register(sarg2) / 10000; \
37458 if(ID < 1 || ID > 255) \
37459 set_register(sarg1, -10000); \
37460 else \
37461 wpnsbuf[ID].member = val; \
37462 }
37463
37464
37465 void FFScript::getSpriteDataTile(){GET_SPRITEDATA_TYPE_INT(tile);}
37466 void FFScript::getSpriteDataMisc(){GET_SPRITEDATA_TYPE_INT(misc);}
37467 void FFScript::getSpriteDataCSets(){GET_SPRITEDATA_TYPE_INT(csets);}
37468 void FFScript::getSpriteDataFrames(){GET_SPRITEDATA_TYPE_INT(frames);}
37469 void FFScript::getSpriteDataSpeed(){GET_SPRITEDATA_TYPE_INT(speed);}
37470 void FFScript::getSpriteDataType(){GET_SPRITEDATA_TYPE_INT(type);}
37471 //void FFScript::getSpriteDataString();
37472
37473
37474
37475 void FFScript::setSpriteDataTile(){SET_SPRITEDATA_TYPE_INT(tile,ZS_WORD);}
37476 void FFScript::setSpriteDataMisc(){SET_SPRITEDATA_TYPE_INT(misc,ZS_CHAR);}
37477 void FFScript::setSpriteDataCSets(){SET_SPRITEDATA_TYPE_INT(csets,ZS_CHAR);}
37478 void FFScript::setSpriteDataFrames(){SET_SPRITEDATA_TYPE_INT(frames,ZS_CHAR);}
37479 void FFScript::setSpriteDataSpeed(){SET_SPRITEDATA_TYPE_INT(speed,ZS_CHAR);}
37480 void FFScript::setSpriteDataType(){SET_SPRITEDATA_TYPE_INT(type,ZS_CHAR);}
37481 //void FFScript::setSpriteDataString();
37482
37483
37484 void FFScript::do_setMIDI_volume(int32_t m)
37485 {
37486 master_volume(-1,(vbound(m,0,255)));
37487 }
37488 void FFScript::do_setMusic_volume(int32_t m)
37489 {
37490 emusic_volume = vbound(m,0,255);
37491 }
37492 void FFScript::do_setDIGI_volume(int32_t m)
37493 {
37494 master_volume((vbound(m,0,255)),-1);
37495 }
37496 void FFScript::do_setSFX_volume(int32_t m)
37497 {
37498 sfx_volume = m;
37499 }
37500 void FFScript::do_setSFX_pan(int32_t m)
37501 {
37502 pan_style = vbound(m,0,3);
37503 }
37504 int32_t FFScript::do_getMIDI_volume()
37505 {
37506 return ((int32_t)midi_volume);
37507 }
37508 int32_t FFScript::do_getMusic_volume()
37509 {
37510 return ((int32_t)emusic_volume);
37511 }
37512 int32_t FFScript::do_getDIGI_volume()
37513 {
37514 return ((int32_t)digi_volume);
37515 }
37516 int32_t FFScript::do_getSFX_volume()
37517 {
37518 return ((int32_t)sfx_volume);
37519 }
37520 int32_t FFScript::do_getSFX_pan()
37521 {
37522 return ((int32_t)pan_style);
37523 }
37524
37525
37526 //Change Game Over Screen Values
37527 void FFScript::FFSetSaveScreenSetting()
37528 {
37529
37530 int32_t indx = get_register(sarg1) / 10000;
37531 int32_t value = get_register(sarg2) / 10000; //bounded in zelda.cpp
37532 if(indx < 0 || indx > 11)
37533 set_register(sarg1, -10000);
37534 else
37535 SetSaveScreenSetting(indx, value);
37536 }
37537
37538
37539
37540 void FFScript::FFChangeSubscreenText()
37541 {
37542
37543 int32_t index = get_register(sarg1) / 10000;
37544 int32_t arrayptr = get_register(sarg2) / 10000;
37545
37546 if ( index < 0 || index > 3 )
37547 {
37548 al_trace("The index supplied to Game->SetSubscreenText() is invalid. The index specified was: %d /n", index);
37549 return;
37550 }
37551
37552 string filename_str;
37553
37554
37555
37556 ArrayH::getString(arrayptr, filename_str, 73);
37557 ChangeSubscreenText(index,filename_str.c_str());
37558
37559 //newtext[32]='\0';
37560
37561
37562
37563 }
37564
37565 void FFScript::do_typedpointer_typecast(const bool v)
37566 {
37567 int32_t ptr = SH::get_arg(sarg1, v);
37568 set_register(sarg1, ptr);
37569 }
37570
37571 void FFScript::SetItemMessagePlayed(int32_t itm)
37572 {
37573 game->item_messages_played[itm] = 1;
37574 }
37575 bool FFScript::GetItemMessagePlayed(int32_t itm)
37576 {
37577 return ((game->item_messages_played[itm] ) ? true : false);
37578 }
37579
37580 int32_t FFScript::getQRBit(int32_t rule)
37581 {
37582 return ( get_qr(rule) ? 1 : 0 );
37583 }
37584
37585 12308206 void FFScript::setHeroAction(int32_t a)
37586 {
37587 12308206 FF_hero_action = vbound(a, 0, 255);
37588 12308206 }
37589
37590 52052790 int32_t FFScript::getHeroAction()
37591 {
37592 52052790 int32_t special_action = Hero.getAction2();
37593
2/2
✓ Branch 0 taken 191669 times.
✓ Branch 1 taken 51861121 times.
52052790 if ( special_action != -1 ) return special_action; //spin, dive, charge
37594 51861121 else return FF_hero_action; //everything else
37595 52052790 }
37596 //get_bit
37597
37598 1307275 int32_t FFScript::GetScriptObjectUID(int32_t type)
37599 {
37600 1307275 ++script_UIDs[type];
37601 1307275 return script_UIDs[type];
37602 }
37603
37604 120 void FFScript::SetNegArray()
37605 {
37606 120 can_neg_array = !get_qr(qr_ZS_NO_NEG_ARRAY);
37607 120 }
37608
37609 407 void FFScript::init()
37610 {
37611 407 eventData.clear();
37612 407 countGenScripts();
37613 407 countObjects();
37614
2/2
✓ Branch 0 taken 4070 times.
✓ Branch 1 taken 407 times.
4477 for ( int32_t q = 0; q < wexLast; q++ ) warpex[q] = 0;
37615 407 print_ZASM = zasm_debugger;
37616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 407 times.
407 if ( zasm_debugger )
37617 {
37618 ZASMPrint(true);
37619 zasm_break_mode = ZASM_BREAK_HALT;
37620 }
37621
37622 407 temp_no_stepforward = 0;
37623 407 nostepforward = 0;
37624
37625 407 can_neg_array = !get_qr(qr_ZS_NO_NEG_ARRAY);
37626
37627 407 numscriptdraws = 0;
37628 407 max_ff_rules = qr_MAX;
37629 407 coreflags = 0;
37630 407 skip_ending_credits = 0;
37631 407 music_update_cond = 0;
37632 407 music_update_flags = 0;
37633 //quest_format : is this properly initialised?
37634
2/2
✓ Branch 0 taken 27676 times.
✓ Branch 1 taken 407 times.
28083 for ( int32_t q = 0; q < susptLAST; q++ ) { system_suspend[q] = 0; }
37635
2/2
✓ Branch 0 taken 1221 times.
✓ Branch 1 taken 407 times.
1628 for ( int32_t q = 0; q < UID_TYPES; ++q ) { script_UIDs[q] = 0; }
37636 //for ( int32_t q = 0; q < 512; q++ ) FF_rules[q] = 0;
37637 407 FFCore.zasm_break_mode = ZASM_BREAK_NONE;
37638
37639 407 usr_midi_volume = midi_volume;
37640 407 usr_digi_volume = digi_volume;
37641 407 usr_sfx_volume = sfx_volume;
37642 407 usr_music_volume = emusic_volume;
37643
37644 407 usr_panstyle = pan_style;
37645 407 FF_hero_action = 0;
37646 407 enemy_removal_point[spriteremovalY1] = -32767;
37647 407 enemy_removal_point[spriteremovalY2] = 32767;
37648 407 enemy_removal_point[spriteremovalX1] = -32767;
37649 407 enemy_removal_point[spriteremovalX2] = 32767;
37650 407 enemy_removal_point[spriteremovalZ1] = -32767;
37651 407 enemy_removal_point[spriteremovalZ2] = 32767;
37652
37653 //Clear internal arrays for use by <std>, <ghost>, <tango>
37654
2/2
✓ Branch 0 taken 104192 times.
✓ Branch 1 taken 407 times.
104599 for ( int32_t q = 0; q < 256; ++q )
37655 {
37656 104192 StdArray[q] = 0;
37657 104192 GhostArray[q] = 0;
37658 104192 TangoArray[q] = 0;
37659 104192 }
37660
37661
2/2
✓ Branch 0 taken 1628 times.
✓ Branch 1 taken 407 times.
2035 for ( int32_t q = 0; q < 4; q++ )
37662 {
37663 1628 FF_screenbounds[q] = 0;
37664 1628 FF_screen_dimensions[q] = 0;
37665 1628 FF_subscreen_dimensions[q] = 0;
37666 1628 FF_eweapon_removal_bounds[q] = 0;
37667 1628 FF_lweapon_removal_bounds[q] = 0;
37668 1628 }
37669
2/2
✓ Branch 0 taken 4070 times.
✓ Branch 1 taken 407 times.
4477 for ( int32_t q = 0; q < FFSCRIPTCLASS_CLOCKS; q++ )
37670 {
37671 4070 FF_clocks[q] = 0;
37672 4070 }
37673
2/2
✓ Branch 0 taken 8140 times.
✓ Branch 1 taken 407 times.
8547 for ( int32_t q = 0; q < SCRIPT_DRAWING_RULES; q++ )
37674 {
37675 8140 ScriptDrawingRules[q] = 0;
37676 8140 }
37677
2/2
✓ Branch 0 taken 2442 times.
✓ Branch 1 taken 407 times.
2849 for ( int32_t q = 0; q < NUM_USER_MIDI_OVERRIDES; q++ )
37678 {
37679 2442 FF_UserMidis[q] = 0;
37680 2442 }
37681 407 subscreen_scroll_speed = 0; //make a define for a default and read quest override! -Z
37682 407 kb_typing_mode = false;
37683 407 initIncludePaths();
37684 407 initRunString();
37685 //clearRunningItemScripts();
37686 407 tempScreens[0] = tmpscr;
37687 407 ScrollingScreens[0] = tmpscr+1;
37688
2/2
✓ Branch 0 taken 2442 times.
✓ Branch 1 taken 407 times.
2849 for(int32_t q = 0; q < 6; ++q)
37689 {
37690 2442 tempScreens[q+1] = tmpscr2+q;
37691 2442 ScrollingScreens[q+1] = tmpscr3+q;
37692 2442 }
37693 407 ScrollingData[SCROLLDATA_DIR] = -1;
37694 407 ScrollingData[SCROLLDATA_NX] = 0;
37695 407 ScrollingData[SCROLLDATA_NY] = 0;
37696 407 ScrollingData[SCROLLDATA_OX] = 0;
37697 407 ScrollingData[SCROLLDATA_OY] = 0;
37698 407 user_rng_init();
37699 407 clear_script_engine_data();
37700
2/2
✓ Branch 0 taken 11272 times.
✓ Branch 1 taken 407 times.
11679 for (auto &it : jitted_scripts)
37701 {
37702 11272 jit_delete_script_handle(it.second);
37703 }
37704 407 jitted_scripts.clear();
37705 407 seen_scripts.clear();
37706 407 script_debug_handles.clear();
37707 407 runtime_script_debug_handle = nullptr;
37708 407 }
37709
37710 void FFScript::shutdown()
37711 {
37712 for (auto &it : jitted_scripts)
37713 {
37714 jit_delete_script_handle(it.second);
37715 }
37716 jitted_scripts.clear();
37717 }
37718
37719
37720 void FFScript::SetFFEngineFlag(int32_t flag, bool state)
37721 {
37722 if ( state ) { coreflags |= flag; }
37723 else coreflags &= ~flag;
37724 }
37725
37726 void FFScript::setSubscreenScrollSpeed(byte n)
37727 {
37728 subscreen_scroll_speed = n;
37729 }
37730
37731 int32_t FFScript::getSubscreenScrollSpeed()
37732 {
37733 return (int32_t)subscreen_scroll_speed;
37734 }
37735
37736 void FFScript::do_greyscale(const bool v)
37737 {
37738 bool on = (SH::get_arg(sarg1, v)) != 0;
37739 setMonochrome(on);
37740 }
37741
37742 void FFScript::do_monochromatic(const bool v)
37743 {
37744 int32_t colour = SH::get_arg(sarg1, v)/10000;
37745 setMonochromatic(colour);
37746 }
37747
37748 void FFScript::gfxmonohue()
37749 {
37750 int32_t _r = SH::read_stack(ri->sp + 3) / 10000;
37751 int32_t _g = SH::read_stack(ri->sp + 2) / 10000;
37752 int32_t _b = SH::read_stack(ri->sp + 1) / 10000;
37753 bool m = (SH::read_stack(ri->sp + 0) / 10000);
37754 doGFXMonohue(_r,_g,_b,m);
37755 }
37756
37757 void FFScript::clearTint()
37758 {
37759 doClearTint();
37760 }
37761
37762 void FFScript::Tint()
37763 {
37764 int32_t _r = SH::read_stack(ri->sp + 2) / 10000;
37765 int32_t _g = SH::read_stack(ri->sp + 1) / 10000;
37766 int32_t _b = SH::read_stack(ri->sp + 0) / 10000;
37767 doTint(_r,_g,_b);
37768 }
37769
37770 void FFScript::do_fx_zap(const bool v)
37771 {
37772 int32_t out = SH::get_arg(sarg1, v);
37773
37774 if ( out ) { FFScript::do_zapout(); }
37775 else FFScript::do_zapin();
37776 }
37777
37778 void FFScript::do_fx_wavy(const bool v)
37779 {
37780 int32_t out = SH::get_arg(sarg1, v);
37781
37782 if ( out ) { FFScript::do_wavyout(); }
37783 else FFScript::do_wavyin();
37784 }
37785
37786 140799159 int32_t FFScript::getQuestHeaderInfo(int32_t type)
37787 {
37788 140799159 return quest_format[type];
37789 }
37790
37791 string get_filestr(const bool relative) //Used for 'FileSystem' functions.
37792 {
37793 int32_t strptr = get_register(sarg1)/10000;
37794 string the_string;
37795 ArrayH::getString(strptr, the_string, 512);
37796 the_string = the_string.substr(the_string.find_first_not_of('/'),string::npos); //Kill leading '/'
37797 size_t last = the_string.find_last_not_of('/');
37798 if(last!=string::npos)++last;
37799 the_string = the_string.substr(0,last); //Kill trailing '/'
37800 if(relative)
37801 {
37802 char buf[2048+1] = {0};
37803 if(FFCore.get_scriptfile_path(buf, the_string.c_str()))
37804 the_string = buf;
37805 }
37806 return the_string;
37807 }
37808
37809 void FFScript::do_checkdir(const bool is_dir)
37810 {
37811 string the_string = get_filestr(get_qr(qr_BITMAP_AND_FILESYSTEM_PATHS_ALWAYS_RELATIVE));
37812 set_register(sarg1, checkPath(the_string.c_str(), is_dir) ? 10000 : 0);
37813 }
37814
37815 void FFScript::do_fs_remove()
37816 {
37817 string the_string = get_filestr(true);
37818 set_register(sarg1, remove(the_string.c_str()) ? 0 : 10000);
37819 }
37820
37821 16 void FFScript::Play_Level_Music()
37822 {
37823 16 int32_t m=tmpscr->screen_midi;
37824
37825
1/6
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 switch(m)
37826 {
37827 case -2:
37828 music_stop();
37829 break;
37830
37831 case -1:
37832 16 play_DmapMusic();
37833 16 break;
37834
37835 case 1:
37836 jukebox(ZC_MIDI_OVERWORLD);
37837 break;
37838
37839 case 2:
37840 jukebox(ZC_MIDI_DUNGEON);
37841 break;
37842
37843 case 3:
37844 jukebox(ZC_MIDI_LEVEL9);
37845 break;
37846
37847 default:
37848 if(m>=4 && m<4+MAXCUSTOMMIDIS)
37849 jukebox(m+MIDIOFFSET_MAPSCR);
37850 else
37851 music_stop();
37852 }
37853 16 }
37854
37855 16 void FFScript::do_warp_ex(bool v)
37856 {
37857 16 int32_t zscript_array_ptr = SH::get_arg(sarg1, v) / 10000;
37858 16 ArrayManager am(zscript_array_ptr);
37859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(am.invalid()) return;
37860 16 int32_t zscript_array_size = am.size();
37861
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
16 switch(zscript_array_size)
37862 {
37863 case 8:
37864 // {int32_t type, int32_t dmap, int32_t screen, int32_t x, int32_t y, int32_t effect, int32_t sound, int32_t flags}
37865 {
37866 if(DEVLOGGING) zprint("FFscript.cpp running do_warp_ex with %d args\n", 8);
37867 16 int32_t tmpwarp[8]={0};
37868
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 16 times.
144 for ( int32_t q = 0; q < wexDir; q++ )
37869 {
37870 128 tmpwarp[q] = (am.get(q)/10000);
37871 128 }
37872
37873
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( ((unsigned)tmpwarp[1]) >= MAXDMAPS )
37874 {
37875 Z_scripterrlog("Invalid DMap ID (%d) passed to WarpEx(). Aborting.\n", tmpwarp[1]);
37876 return;
37877 }
37878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( ((unsigned)tmpwarp[2]) >= MAPSCRS )
37879 {
37880 Z_scripterrlog("Invalid Screen ID (%d) passed to WarpEx(). Aborting.\n", tmpwarp[2]);
37881 return;
37882 }
37883 //Extra sanity guard.
37884
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ( DMaps[tmpwarp[1]].map*MAPSCRS+DMaps[tmpwarp[1]].xoff+tmpwarp[2] >= (int32_t)TheMaps.size() )
37885 {
37886 Z_scripterrlog("Invalid destination passed to WarpEx(). Aborting.\n");
37887 return;
37888 }
37889 //If we passed the sanity checks, populate the FFCore array and begin the action!
37890
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 16 times.
144 for ( int32_t q = 0; q < wexDir; q++ )
37891 {
37892 128 FFCore.warpex[q] = tmpwarp[q];
37893 128 }
37894 16 FFCore.warpex[wexActive] = 1;
37895 16 FFCore.warpex[wexDir] = -1;
37896
37897 16 break;
37898 }
37899 case 9:
37900 // {int32_t type, int32_t dmap, int32_t screen, int32_t x, int32_t y, int32_t effect, int32_t sound, int32_t flags, int32_t dir}
37901 {
37902 if(DEVLOGGING) zprint("FFscript.cpp running do_warp_ex with %d args\n", 9);
37903 int32_t tmpwarp[9]={0};
37904
37905 for ( int32_t q = 0; q < wexActive; q++ )
37906 {
37907 tmpwarp[q] = (am.get(q)/10000);
37908 }
37909
37910 if ( ((unsigned)tmpwarp[1]) >= MAXDMAPS )
37911 {
37912 Z_scripterrlog("Invalid DMap ID (%d) passed to WarpEx(). Aborting.\n", tmpwarp[1]);
37913 return;
37914 }
37915 if ( ((unsigned)tmpwarp[2]) >= MAPSCRS )
37916 {
37917 Z_scripterrlog("Invalid Screen ID (%d) passed to WarpEx(). Aborting.\n", tmpwarp[2]);
37918 return;
37919 }
37920 //Extra sanity guard.
37921 if ( DMaps[tmpwarp[1]].map*MAPSCRS+DMaps[tmpwarp[1]].xoff+tmpwarp[2] >= (int32_t)TheMaps.size() )
37922 {
37923 Z_scripterrlog("Invalid destination passed to WarpEx(). Aborting.\n");
37924 return;
37925 }
37926 //If we passed the sanity checks, populate the FFCore array and begin the action!
37927 for ( int32_t q = 0; q < wexActive; q++ )
37928 {
37929 FFCore.warpex[q] = tmpwarp[q];
37930 }
37931 FFCore.warpex[wexActive] = 1;
37932
37933 for ( int32_t q = 0; q < wexActive; q++ )
37934 {
37935 FFCore.warpex[q] = tmpwarp[q];
37936 }
37937
37938 //for ( int32_t q = 0; q < wexLast; q++ )
37939 //{
37940 // zprint("FFCore.warpex[%d] is: %d\n", q, FFCore.warpex[q]);
37941 //}
37942
37943 break;
37944
37945 }
37946
37947 default:
37948 {
37949 Z_scripterrlog("Array supplied to Player->WarpEx() is the wrong size!\n The array size was: &d, and valid sizes are [8] and [9].\n",zscript_array_size);
37950 break;
37951 }
37952
37953
37954
37955 }
37956 16 }
37957
37958 ///////////////////////////////
37959 //* SCRIPT ENGINE FUNCTIONS *//
37960 ////////////////////////////////////////////////////////////////////////////
37961
37962 void FFScript::clearRunningItemScripts()
37963 {
37964 //for ( byte q = 0; q < 256; q++ ) runningItemScripts[q] = 0;
37965 }
37966
37967
37968 4995 void FFScript::warpScriptCheck()
37969 {
37970
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4995 times.
4995 if(get_qr(qr_SCRIPTDRAWSINWARPS))
37971 {
37972 FFCore.runWarpScripts(false);
37973 FFCore.runWarpScripts(true); //Waitdraw
37974 }
37975
3/4
✓ Branch 0 taken 87 times.
✓ Branch 1 taken 4908 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 87 times.
4995 else if(get_qr(qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN) && doscript(ScriptType::PassiveSubscreen))
37976 {
37977
1/2
✓ Branch 0 taken 87 times.
✗ Branch 1 not taken.
87 if(DMaps[currdmap].passive_sub_script != 0)
37978 ZScriptVersion::RunScript(ScriptType::PassiveSubscreen, DMaps[currdmap].passive_sub_script, currdmap);
37979
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 87 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
87 if (waitdraw(ScriptType::PassiveSubscreen) && DMaps[currdmap].passive_sub_script != 0 && doscript(ScriptType::PassiveSubscreen))
37980 {
37981 ZScriptVersion::RunScript(ScriptType::PassiveSubscreen, DMaps[currdmap].passive_sub_script, currdmap);
37982 waitdraw(ScriptType::PassiveSubscreen) = false;
37983 }
37984 87 }
37985 4995 }
37986
37987 void FFScript::runWarpScripts(bool waitdraw)
37988 {
37989 if(waitdraw)
37990 {
37991 if ((!( FFCore.system_suspend[susptGLOBALGAME] )) && FFCore.waitdraw(ScriptType::Global, GLOBAL_SCRIPT_GAME))
37992 {
37993 ZScriptVersion::RunScript(ScriptType::Global, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
37994 FFCore.waitdraw(ScriptType::Global, GLOBAL_SCRIPT_GAME) = false;
37995 }
37996 if ( !FFCore.system_suspend[susptITEMSCRIPTENGINE] )
37997 {
37998 FFCore.itemScriptEngineOnWaitdraw();
37999 }
38000 if ( (!( FFCore.system_suspend[susptHEROACTIVE] )) && FFCore.waitdraw(ScriptType::Player) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
38001 {
38002 ZScriptVersion::RunScript(ScriptType::Player, SCRIPT_PLAYER_ACTIVE);
38003 FFCore.waitdraw(ScriptType::Player) = false;
38004 }
38005 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && FFCore.waitdraw(ScriptType::DMap) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
38006 {
38007 ZScriptVersion::RunScript(ScriptType::DMap, DMaps[currdmap].script,currdmap);
38008 FFCore.waitdraw(ScriptType::DMap) = false;
38009 }
38010 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && FFCore.waitdraw(ScriptType::PassiveSubscreen) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
38011 {
38012 ZScriptVersion::RunScript(ScriptType::PassiveSubscreen, DMaps[currdmap].passive_sub_script,currdmap);
38013 FFCore.waitdraw(ScriptType::PassiveSubscreen) = false;
38014 }
38015 //if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && active_subscreen_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
38016 //{
38017 // ZScriptVersion::RunScript(ScriptType::Subscreen, DMaps[currdmap].activesubscript,currdmap);
38018 // passive_subscreen_waitdraw = false;
38019 //}
38020 //no doscript check here, becauseb of preload? Do we want to write doscript here? -Z 13th July, 2019
38021 if ( (!( FFCore.system_suspend[susptSCREENSCRIPTS] )) && tmpscr->script != 0 && FFCore.waitdraw(ScriptType::Screen) && tmpscr->preloadscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
38022 {
38023 ZScriptVersion::RunScript(ScriptType::Screen, tmpscr->script);
38024 FFCore.waitdraw(ScriptType::Screen) = 0;
38025 }
38026 }
38027 else
38028 {
38029 if ((!( FFCore.system_suspend[susptGLOBALGAME] )) && FFCore.doscript(ScriptType::Global, GLOBAL_SCRIPT_GAME))
38030 {
38031 ZScriptVersion::RunScript(ScriptType::Global, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
38032 }
38033 if ( !FFCore.system_suspend[susptITEMSCRIPTENGINE] )
38034 {
38035 FFCore.itemScriptEngine();
38036 }
38037 if ((!( FFCore.system_suspend[susptHEROACTIVE] )) && doscript(ScriptType::Player) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255)
38038 {
38039 ZScriptVersion::RunScript(ScriptType::Player, SCRIPT_PLAYER_ACTIVE);
38040 }
38041 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && doscript(ScriptType::DMap) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
38042 {
38043 ZScriptVersion::RunScript(ScriptType::DMap, DMaps[currdmap].script,currdmap);
38044 }
38045 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && FFCore.doscript(ScriptType::PassiveSubscreen) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
38046 {
38047 ZScriptVersion::RunScript(ScriptType::PassiveSubscreen, DMaps[currdmap].passive_sub_script,currdmap);
38048 }
38049 if ( (!( FFCore.system_suspend[susptSCREENSCRIPTS] )) && tmpscr->script != 0 && tmpscr->preloadscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
38050 {
38051 ZScriptVersion::RunScript(ScriptType::Screen, tmpscr->script);
38052 }
38053 }
38054 }
38055
38056 17421508 void FFScript::runF6Engine()
38057 {
38058
5/6
✓ Branch 0 taken 17420822 times.
✓ Branch 1 taken 686 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 17420809 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 13 times.
17421508 if(!Quit && (GameFlags&GAMEFLAG_TRYQUIT) && !(GameFlags&GAMEFLAG_F6SCRIPT_ACTIVE))
38059 {
38060
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(globalscripts[GLOBAL_SCRIPT_F6]->valid())
38061 {
38062 //Incase this was called mid-another script, store ref data
38063 push_ri();
38064 //
38065 clear_bitmap(f6_menu_buf);
38066 blit(framebuf, f6_menu_buf, 0, 0, 0, 0, 256, 224);
38067 initZScriptGlobalScript(GLOBAL_SCRIPT_F6);
38068 int32_t openingwipe = black_opening_count;
38069 int32_t openingshape = black_opening_shape;
38070 black_opening_count = 0; //No opening wipe during F6 menu
38071 if(black_opening_shape==bosFADEBLACK) black_fade(0);
38072 GameFlags |= GAMEFLAG_F6SCRIPT_ACTIVE;
38073 //auto tmpDrawCommands = script_drawing_commands.pop_commands();
38074 pause_all_sfx();
38075
38076 auto& data = get_script_engine_data(ScriptType::Global, GLOBAL_SCRIPT_F6);
38077 while (data.doscript)
38078 {
38079 script_drawing_commands.Clear();
38080 load_control_state();
38081 ZScriptVersion::RunScript(ScriptType::Global, GLOBAL_SCRIPT_F6, GLOBAL_SCRIPT_F6);
38082 if (data.waitdraw)
38083 {
38084 ZScriptVersion::RunScript(ScriptType::Global, GLOBAL_SCRIPT_F6, GLOBAL_SCRIPT_F6);
38085 data.waitdraw = false;
38086 }
38087 //Draw
38088 clear_bitmap(framebuf);
38089 if( !FFCore.system_suspend[susptCOMBOANIM] ) animate_combos();
38090 doScriptMenuDraws();
38091 //
38092 advanceframe(true,true,false);
38093 if(Quit) break; //Something quit, end script running
38094 }
38095 resume_all_sfx();
38096 script_drawing_commands.Clear();
38097 //script_drawing_commands.push_commands(tmpDrawCommands);
38098 GameFlags &= ~GAMEFLAG_F6SCRIPT_ACTIVE;
38099 //Restore opening wipe
38100 black_opening_count = openingwipe;
38101 black_opening_shape = openingshape;
38102 if(openingshape == bosFADEBLACK)
38103 {
38104 refreshTints();
38105 memcpy(tempblackpal, RAMpal, PAL_SIZE*sizeof(RGB));
38106 }
38107 //Restore script refinfo
38108 pop_ri();
38109 //
38110 if(!Quit)
38111 {
38112 if(!get_qr(qr_NOCONTINUE))
38113 f_Quit(qQUIT);
38114 }
38115 }
38116 13 else f_Quit(qQUIT);
38117 13 zc_readkey(KEY_F6);
38118 13 GameFlags &= ~GAMEFLAG_TRYQUIT;
38119 13 }
38120 17421508 }
38121 void FFScript::runOnDeathEngine()
38122 {
38123 if(!playerscripts[SCRIPT_PLAYER_DEATH]->valid()) return; //No script to run
38124 clear_bitmap(script_menu_buf);
38125 blit(framebuf, script_menu_buf, 0, 0, 0, 0, 256, 224);
38126 initZScriptHeroScripts();
38127 GameFlags |= GAMEFLAG_SCRIPTMENU_ACTIVE;
38128 kill_sfx(); //No need to pause/resume; the player is dead.
38129 //auto tmpDrawCommands = script_drawing_commands.pop_commands();
38130
38131 auto& data = get_script_engine_data(ScriptType::Player);
38132 while (data.doscript && !Quit)
38133 {
38134 script_drawing_commands.Clear();
38135 load_control_state();
38136 ZScriptVersion::RunScript(ScriptType::Player, SCRIPT_PLAYER_DEATH);
38137 if (data.waitdraw)
38138 {
38139 ZScriptVersion::RunScript(ScriptType::Player, SCRIPT_PLAYER_DEATH);
38140 data.waitdraw = false;
38141 }
38142 //Draw
38143 clear_bitmap(framebuf);
38144 if( !FFCore.system_suspend[susptCOMBOANIM] ) animate_combos();
38145 doScriptMenuDraws();
38146 //
38147 advanceframe(true);
38148 }
38149 script_drawing_commands.Clear();
38150 //script_drawing_commands.push_commands(tmpDrawCommands);
38151 GameFlags &= ~GAMEFLAG_SCRIPTMENU_ACTIVE;
38152 }
38153 120 void FFScript::runOnLaunchEngine()
38154 {
38155
2/2
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 1 times.
120 if(!globalscripts[GLOBAL_SCRIPT_ONLAUNCH]->valid()) return; //No script to run
38156 //Do NOT blit the prior screen to this bitmap; that would be the TITLE SCREEN.
38157 1 clear_to_color(script_menu_buf,BLACK);
38158 1 initZScriptGlobalScript(GLOBAL_SCRIPT_ONLAUNCH);
38159 1 GameFlags |= GAMEFLAG_SCRIPTMENU_ACTIVE;
38160 //auto tmpDrawCommands = script_drawing_commands.pop_commands();
38161
38162 1 auto& data = get_script_engine_data(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH);
38163
4/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
2 while (data.doscript && !Quit)
38164 {
38165 1 script_drawing_commands.Clear();
38166 1 load_control_state();
38167 1 ZScriptVersion::RunScript(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH, GLOBAL_SCRIPT_ONLAUNCH);
38168
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (data.waitdraw)
38169 {
38170 ZScriptVersion::RunScript(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH, GLOBAL_SCRIPT_ONLAUNCH);
38171 data.waitdraw = false;
38172 }
38173 //Draw
38174 1 clear_bitmap(framebuf);
38175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if( !FFCore.system_suspend[susptCOMBOANIM] ) animate_combos();
38176
38177 1 doScriptMenuDraws();
38178 //
38179 1 advanceframe(true);
38180 }
38181 1 script_drawing_commands.Clear();
38182 //script_drawing_commands.push_commands(tmpDrawCommands);
38183 1 GameFlags &= ~GAMEFLAG_SCRIPTMENU_ACTIVE;
38184 120 }
38185 10 bool FFScript::runGenericFrozenEngine(const word script)
38186 {
38187 static int32_t local_i = 0;
38188
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
10 if(script < 1 || script >= NUMSCRIPTSGENERIC) return false;
38189
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(!genericscripts[script]->valid()) return false; //No script to run
38190 //Store script refinfo
38191 10 push_ri();
38192 refInfo local_ri;
38193 int32_t local_stack[MAX_SCRIPT_REGISTERS];
38194 10 local_ri.Clear();
38195 10 memset(local_stack, 0, sizeof(local_stack));
38196 10 genericActiveData.push_back(&local_ri);
38197 10 generic_active_stack.push_back(&local_stack);
38198 10 bool tmp_init = gen_active_initialized;
38199 10 bool tmp_doscript = gen_active_doscript;
38200 10 gen_active_doscript = true;
38201 10 gen_active_initialized = false;
38202 //run script
38203 10 uint32_t fl = GameFlags & GAMEFLAG_SCRIPTMENU_ACTIVE;
38204 10 BITMAP* tmpbuf = script_menu_buf;
38205
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(fl)
38206 {
38207 script_menu_buf = create_bitmap_ex(8,256,224);
38208 }
38209 10 clear_bitmap(script_menu_buf);
38210 10 blit(framebuf, script_menu_buf, 0, 0, 0, 0, 256, 224);
38211 10 GameFlags |= GAMEFLAG_SCRIPTMENU_ACTIVE;
38212 10 ++local_i;
38213 //auto tmpDrawCommands = script_drawing_commands.pop_commands();
38214
4/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 1542 times.
✓ Branch 2 taken 1542 times.
✓ Branch 3 taken 10 times.
1552 while(gen_active_doscript && !Quit)
38215 {
38216 1542 script_drawing_commands.Clear();
38217 1542 load_control_state();
38218 1542 ZScriptVersion::RunScript(ScriptType::GenericFrozen, script, local_i);
38219 //Draw
38220 1542 clear_bitmap(framebuf);
38221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1542 times.
1542 if( !FFCore.system_suspend[susptCOMBOANIM] ) animate_combos();
38222 1542 doScriptMenuDraws();
38223 //
38224 1542 advanceframe(true);
38225 }
38226 10 script_drawing_commands.Clear();
38227 //script_drawing_commands.push_commands(tmpDrawCommands);
38228 10 --local_i;
38229 10 gen_active_doscript = tmp_doscript;
38230 10 gen_active_initialized = tmp_init;
38231 //clear
38232 10 GameFlags &= ~GAMEFLAG_SCRIPTMENU_ACTIVE;
38233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(fl)
38234 {
38235 GameFlags |= fl;
38236 destroy_bitmap(script_menu_buf);
38237 script_menu_buf = tmpbuf;
38238 }
38239 10 genericActiveData.pop_back();
38240 10 generic_active_stack.pop_back();
38241 //Restore script refinfo
38242 10 pop_ri();
38243 10 return true;
38244 10 }
38245
38246 794 bool FFScript::runActiveSubscreenScriptEngine()
38247 {
38248 794 word activesubscript = DMaps[currdmap].active_sub_script;
38249
3/4
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 754 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 40 times.
794 if(!activesubscript || !dmapscripts[activesubscript]->valid()) return false; //No script to run
38250 40 word passivesubscript = DMaps[currdmap].passive_sub_script;
38251 40 word dmapactivescript = DMaps[currdmap].script;
38252 40 clear_bitmap(script_menu_buf);
38253 40 blit(framebuf, script_menu_buf, 0, 0, 0, 0, 256, 224);
38254 40 initZScriptActiveSubscreenScript();
38255 40 GameFlags |= GAMEFLAG_SCRIPTMENU_ACTIVE;
38256 40 word script_dmap = currdmap;
38257 //auto tmpDrawCommands = script_drawing_commands.pop_commands();
38258 40 pause_all_sfx();
38259 40 auto& data = get_script_engine_data(ScriptType::ActiveSubscreen);
38260
4/4
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 6632 times.
✓ Branch 2 taken 6632 times.
✓ Branch 3 taken 40 times.
6672 while (data.doscript && !Quit)
38261 {
38262 6632 script_drawing_commands.Clear();
38263 6632 load_control_state();
38264
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6632 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6632 if(get_qr(qr_DMAP_ACTIVE_RUNS_DURING_ACTIVE_SUBSCRIPT) && DMaps[script_dmap].script != 0 && doscript(ScriptType::DMap))
38265 {
38266 ZScriptVersion::RunScript(ScriptType::DMap, dmapactivescript, script_dmap);
38267 }
38268
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6632 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6632 if(get_qr(qr_PASSIVE_SUBSCRIPT_RUNS_DURING_ACTIVE_SUBSCRIPT)!=0 && DMaps[script_dmap].passive_sub_script != 0 && FFCore.doscript(ScriptType::PassiveSubscreen))
38269 {
38270 ZScriptVersion::RunScript(ScriptType::PassiveSubscreen, passivesubscript, script_dmap);
38271 }
38272 6632 ZScriptVersion::RunScript(ScriptType::ActiveSubscreen, activesubscript, script_dmap);
38273
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6632 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6632 if(waitdraw(ScriptType::DMap) && (get_qr(qr_DMAP_ACTIVE_RUNS_DURING_ACTIVE_SUBSCRIPT) && DMaps[script_dmap].script != 0 && doscript(ScriptType::DMap)))
38274 {
38275 ZScriptVersion::RunScript(ScriptType::DMap, dmapactivescript, script_dmap);
38276 waitdraw(ScriptType::DMap) = false;
38277 }
38278
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6632 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6632 if(waitdraw(ScriptType::PassiveSubscreen) && (get_qr(qr_PASSIVE_SUBSCRIPT_RUNS_DURING_ACTIVE_SUBSCRIPT)!=0 && DMaps[script_dmap].passive_sub_script != 0 && FFCore.doscript(ScriptType::PassiveSubscreen)))
38279 {
38280 ZScriptVersion::RunScript(ScriptType::PassiveSubscreen, passivesubscript, script_dmap);
38281 waitdraw(ScriptType::PassiveSubscreen) = false;
38282 }
38283
3/4
✓ Branch 0 taken 5472 times.
✓ Branch 1 taken 1160 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5472 times.
6632 if (data.waitdraw && data.doscript)
38284 {
38285 5472 ZScriptVersion::RunScript(ScriptType::ActiveSubscreen, activesubscript, script_dmap);
38286 5472 data.waitdraw = false;
38287 5472 }
38288 //Draw
38289 6632 clear_bitmap(framebuf);
38290
2/4
✓ Branch 0 taken 6632 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6632 times.
6632 if(currdmap == script_dmap && ( !FFCore.system_suspend[susptCOMBOANIM] ) ) animate_combos();
38291 6632 doScriptMenuDraws();
38292 //
38293 6632 advanceframe(true);
38294 //Handle warps; run game_loop once!
38295
1/2
✓ Branch 0 taken 6632 times.
✗ Branch 1 not taken.
6632 if(currdmap != script_dmap)
38296 {
38297 activesubscript = DMaps[currdmap].active_sub_script;
38298 if(!activesubscript || !dmapscripts[activesubscript]->valid()) return true; //No script to run
38299 passivesubscript = DMaps[currdmap].passive_sub_script;
38300 dmapactivescript = DMaps[currdmap].script;
38301 script_dmap = currdmap;
38302 //Reset the background image
38303 game_loop();
38304 clear_bitmap(script_menu_buf);
38305 blit(framebuf, script_menu_buf, 0, 0, 0, 0, 256, 224);
38306 //Now loop without advancing frame, so that the subscreen script can draw immediately.
38307 }
38308 }
38309 40 resume_all_sfx();
38310 40 script_drawing_commands.Clear();
38311 //script_drawing_commands.push_commands(tmpDrawCommands);
38312 40 GameFlags &= ~GAMEFLAG_SCRIPTMENU_ACTIVE;
38313 40 GameFlags |= GAMEFLAG_RESET_GAME_LOOP;
38314 40 return true;
38315 794 }
38316 417 bool FFScript::runOnMapScriptEngine()
38317 {
38318 417 word onmap_script = DMaps[currdmap].onmap_script;
38319
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 417 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
417 if(!onmap_script || !dmapscripts[onmap_script]->valid()) return false; //No script to run
38320 clear_bitmap(script_menu_buf);
38321 blit(framebuf, script_menu_buf, 0, 0, 0, 0, 256, 224);
38322 initZScriptOnMapScript();
38323 GameFlags |= GAMEFLAG_SCRIPTMENU_ACTIVE;
38324 word script_dmap = currdmap;
38325 //auto tmpDrawCommands = script_drawing_commands.pop_commands();
38326 pause_all_sfx();
38327
38328 auto& data = get_script_engine_data(ScriptType::OnMap);
38329 while (data.doscript && !Quit)
38330 {
38331 script_drawing_commands.Clear();
38332 load_control_state();
38333 ZScriptVersion::RunScript(ScriptType::OnMap, onmap_script, script_dmap);
38334 if (data.waitdraw && data.doscript)
38335 {
38336 ZScriptVersion::RunScript(ScriptType::OnMap, onmap_script, script_dmap);
38337 data.waitdraw = false;
38338 }
38339 //Draw
38340 clear_bitmap(framebuf);
38341 if(currdmap == script_dmap && ( !FFCore.system_suspend[susptCOMBOANIM] ) ) animate_combos();
38342 doScriptMenuDraws();
38343 //
38344 advanceframe(true);
38345 //Handle warps; run game_loop once!
38346 if(currdmap != script_dmap)
38347 {
38348 onmap_script = DMaps[currdmap].onmap_script;
38349 if(!onmap_script || !dmapscripts[onmap_script]->valid()) return true; //No script to run
38350 script_dmap = currdmap;
38351 //Reset the background image
38352 game_loop();
38353 clear_bitmap(script_menu_buf);
38354 blit(framebuf, script_menu_buf, 0, 0, 0, 0, 256, 224);
38355 //Now loop without advancing frame, so that the subscreen script can draw immediately.
38356 }
38357 }
38358 resume_all_sfx();
38359 script_drawing_commands.Clear();
38360 //script_drawing_commands.push_commands(tmpDrawCommands);
38361 GameFlags &= ~GAMEFLAG_SCRIPTMENU_ACTIVE;
38362 GameFlags |= GAMEFLAG_RESET_GAME_LOOP;
38363 return true;
38364 417 }
38365
38366 8175 void FFScript::doScriptMenuDraws()
38367 {
38368
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8175 times.
8175 BITMAP* menu_buf = ((GameFlags & GAMEFLAG_F6SCRIPT_ACTIVE) != 0) ? f6_menu_buf : script_menu_buf;
38369 8175 blit(menu_buf, framebuf, 0, 0, 0, 0, 256, 224);
38370 //Script draws
38371 8175 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
38372 8175 }
38373
38374 102 void FFScript::runOnSaveEngine()
38375 {
38376
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(globalscripts[GLOBAL_SCRIPT_ONSAVE]->valid())
38377 {
38378 push_ri();
38379 //Prevent getting here via Quit from causing a forced-script-quit after 1000 commands!
38380 int32_t tQuit = Quit;
38381 Quit = 0;
38382 //
38383 initZScriptGlobalScript(GLOBAL_SCRIPT_ONSAVE);
38384 ZScriptVersion::RunScript(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE, GLOBAL_SCRIPT_ONSAVE);
38385 //
38386 pop_ri();
38387 Quit = tQuit;
38388 }
38389 102 }
38390
38391 8066367 bool FFScript::itemScriptEngine()
38392 {
38393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8066367 times.
8066367 if ( FFCore.system_suspend[susptITEMSCRIPTENGINE] ) return false;
38394 //zprint("Trying to check if an %s is running.\n","item script");
38395
2/2
✓ Branch 0 taken 2064989952 times.
✓ Branch 1 taken 8066367 times.
2073056319 for ( int32_t q = 0; q < MAXITEMS; q++ )
38396 {
38397
38398 //zprint("Checking item ID: %d\n",q);
38399
3/4
✓ Branch 0 taken 18893643 times.
✓ Branch 1 taken 2046096309 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18893643 times.
2064989952 if ( itemsbuf[q].script <= 0 || itemsbuf[q].script > NUMSCRIPTITEM ) continue; // > NUMSCRIPTITEM as someone could force an invaid script slot!
38400
38401 18893643 auto& data = get_script_engine_data(ScriptType::Item, q);
38402
2/2
✓ Branch 0 taken 3306 times.
✓ Branch 1 taken 18890337 times.
18893643 if ( data.doscript < 1 ) continue;
38403
38404 //Passive items
38405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3306 times.
3306 if (((itemsbuf[q].flags&ITEM_PASSIVESCRIPT)))
38406 {
38407 if(game->item[q] && (get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
38408 {
38409 if(get_qr(qr_PASSIVE_ITEM_SCRIPT_ONLY_HIGHEST)
38410 && current_item(itemsbuf[q].family) > itemsbuf[q].fam_type)
38411 data.doscript = 0;
38412 else ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[q].script, q&0xFFF);
38413 if(!data.doscript) //Item script ended. Clear the data, if any remains.
38414 {
38415 data.ref.Clear();
38416 data.initialized = false;
38417 data.waitdraw = false;
38418 FFScript::deallocateAllArrays(ScriptType::Item, q);
38419 }
38420 }
38421 }
38422 else
38423 {
38424
38425 //Normal Items
38426 //zprint("Running ItemScriptEngine() for item ID: %dn", q);
38427 /*! What happens here: When an item script is first run by the user using that utem, the script runs for one frame.
38428 After executing RunScript(), item_doscript is set to '1' in hero.cpp.
38429 If the quest allows the item to continue running, the itemScriptEngine() function ignores running the
38430 same item script (again) that frame, and insteads increments item_doscript to '2'.
38431 If item_doscript == 2, then we know we are on the second frame, and we run it perpetually.
38432 If the QR to enable item scripts to run for more than one frame is not enabled, then item_doscript is set to '0'.
38433 If the item flag 'PERPETUAL SCRIPT' is enabled, then we ignore the lack of item_doscript==2.
38434 This allows passive item scripts to function.
38435 */
38436
38437 3306 auto& data = get_script_engine_data(ScriptType::Item, q);
38438
38439
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3293 times.
3306 if ( data.doscript == 1 ) // FIrst frame, normally set in hero.cpp
38440 {
38441
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if ( get_qr(qr_ITEMSCRIPTSKEEPRUNNING) )
38442 {
38443 13 data.doscript = 2;
38444 13 }
38445 13 }
38446
1/2
✓ Branch 0 taken 3293 times.
✗ Branch 1 not taken.
3293 else if (data.doscript == 2) //Second frame and later, if scripts continue to run.
38447 {
38448 3293 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[q].script, q&0xFFF);
38449 3293 }
38450 else if (data.doscript == 3) //Run via itemdata->RunScript
38451 {
38452 if ( (get_qr(qr_ITEMSCRIPTSKEEPRUNNING)) )
38453 {
38454 data.doscript = 2; //Reduce to normal run status
38455 }
38456 else
38457 {
38458 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[q].script, q & 0xFFF);
38459 data.doscript = 0;
38460 }
38461 }
38462 else if(data.doscript==4) //Item set itself false, kill script and clear data here
38463 {
38464 data.doscript = 0;
38465 }
38466
2/2
✓ Branch 0 taken 3278 times.
✓ Branch 1 taken 28 times.
3306 if(data.doscript==0) //Item script ended. Clear the data, if any remains.
38467 {
38468 28 data.ref.Clear();
38469 28 data.initialized = false;
38470 28 data.waitdraw = false;
38471 28 FFScript::deallocateAllArrays(ScriptType::Item, q);
38472 28 }
38473 }
38474 3306 }
38475 8066367 return false;
38476 8066367 }
38477
38478 8153332 bool FFScript::itemScriptEngineOnWaitdraw()
38479 {
38480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8153332 times.
8153332 if ( FFCore.system_suspend[susptITEMSCRIPTENGINE] ) return false;
38481 //zprint("Trying to check if an %s is running.\n","item script");
38482
2/2
✓ Branch 0 taken 2087252992 times.
✓ Branch 1 taken 8153332 times.
2095406324 for ( int32_t q = 0; q < MAXITEMS; q++ )
38483 {
38484 //zprint("Checking item ID: %d\n",q);
38485
3/4
✓ Branch 0 taken 19396249 times.
✓ Branch 1 taken 2067856743 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19396249 times.
2087252992 if ( itemsbuf[q].script <= 0 || itemsbuf[q].script > NUMSCRIPTITEM ) continue; // > NUMSCRIPTITEM as someone could force an invaid script slot!
38486
38487 19396249 auto& data = get_script_engine_data(ScriptType::Item, q);
38488
38489
2/2
✓ Branch 0 taken 3278 times.
✓ Branch 1 taken 19392971 times.
19396249 if ( data.doscript < 1 ) continue;
38490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3278 times.
3278 if (!data.waitdraw) continue;
38491 else data.waitdraw = false;
38492
38493 //zprint("Running ItemScriptEngine() for item ID: %dn", q);
38494 /*! What happens here: When an item script is first run by the user using that utem, the script runs for one frame.
38495 After executing RunScript(), item_doscript is set to '1' in hero.cpp.
38496 If the quest allows the item to continue running, the itemScriptEngine() function ignores running the
38497 same item script (again) that frame, and insteads increments item_doscript to '2'.
38498 If item_doscript == 2, then we know we are on the second frame, and we run it perpetually.
38499 If the QR to enable item scripts to run for more than one frame is not enabled, then item_doscript is set to '0'.
38500 If the item flag 'PERPETUAL SCRIPT' is enabled, then we ignore the lack of item_doscript==2.
38501 This allows passive item scripts to function.
38502 */
38503 //Passive items
38504 if ((itemsbuf[q].flags&ITEM_PASSIVESCRIPT))
38505 {
38506 if(game->item[q] && (get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
38507 {
38508 if(get_qr(qr_PASSIVE_ITEM_SCRIPT_ONLY_HIGHEST)
38509 && current_item(itemsbuf[q].family) > itemsbuf[q].fam_type)
38510 data.doscript = 0;
38511 else ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[q].script, q&0xFFF);
38512 if(!data.doscript) //Item script ended. Clear the data, if any remains.
38513 {
38514 data.ref.Clear();
38515 data.initialized = false;
38516 data.waitdraw = false;
38517 FFScript::deallocateAllArrays(ScriptType::Item, q);
38518 }
38519 }
38520 }
38521 else
38522 {
38523 //Normal items
38524 if ( data.doscript == 1 ) // FIrst frame, normally set in hero.cpp
38525 {
38526 if ( get_qr(qr_ITEMSCRIPTSKEEPRUNNING) )
38527 {
38528 data.doscript = 2;
38529 }
38530 else data.doscript = 0;
38531 }
38532 else if (data.doscript == 2) //Second frame and later, if scripts continue to run.
38533 {
38534 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[q].script, q&0xFFF);
38535 }
38536 else if (data.doscript == 3) //Run via itemdata->RunScript
38537 {
38538 if ( (get_qr(qr_ITEMSCRIPTSKEEPRUNNING)) )
38539 {
38540 data.doscript = 2; //Reduce to normal run status
38541 }
38542 else
38543 {
38544 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[q].script, q & 0xFFF);
38545 data.doscript = 0;
38546 }
38547 }
38548 else if(data.doscript==4) //Item set itself false, kill script and clear data here.
38549 {
38550 data.doscript = 0;
38551 }
38552 if(!data.doscript) //Item script ended. Clear the data, if any remains.
38553 {
38554 data.ref.Clear();
38555 data.initialized = false;
38556 data.waitdraw = false;
38557 FFScript::deallocateAllArrays(ScriptType::Item, q);
38558 }
38559 }
38560 }
38561 8153332 return false;
38562 8153332 }
38563 7335061 void FFScript::npcScriptEngineOnWaitdraw()
38564 {
38565
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7335061 times.
7335061 if ( FFCore.system_suspend[susptNPCSCRIPTS] ) return;
38566 7335061 guys.run_script(MODE_WAITDRAW);
38567 7335061 }
38568
38569 7260791 void FFScript::eweaponScriptEngine()
38570 {
38571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7260791 times.
7260791 if ( FFCore.system_suspend[susptEWEAPONSCRIPTS] ) return;
38572 7260791 Ewpns.run_script(MODE_NORMAL);
38573 7260791 }
38574
38575 7335061 void FFScript::lweaponScriptEngineOnWaitdraw()
38576 {
38577
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7335061 times.
7335061 if ( FFCore.system_suspend[susptLWEAPONSCRIPTS] ) return;
38578 7335061 Lwpns.run_script(MODE_WAITDRAW);
38579 7335061 }
38580
38581 7347946 void FFScript::eweaponScriptEngineOnWaitdraw()
38582 {
38583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7347946 times.
7347946 if ( FFCore.system_suspend[susptEWEAPONSCRIPTS] ) return;
38584 7347946 Ewpns.run_script(MODE_WAITDRAW);
38585 7347946 }
38586
38587 7260791 void FFScript::itemSpriteScriptEngine()
38588 {
38589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7260791 times.
7260791 if ( FFCore.system_suspend[susptITEMSPRITESCRIPTS] ) return;
38590 7260791 items.run_script(MODE_NORMAL);
38591 7260791 }
38592
38593 7347946 void FFScript::itemSpriteScriptEngineOnWaitdraw()
38594 {
38595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7347946 times.
7347946 if ( FFCore.system_suspend[susptITEMSPRITESCRIPTS] ) return;
38596 7347946 items.run_script(MODE_WAITDRAW);
38597 7347946 }
38598
38599
38600 int32_t FFScript::getTime(int32_t type)
38601 {
38602 //struct tm *tm_struct = localtime(time(NULL));
38603 struct tm * tm_struct;
38604 time_t sysRTC;
38605 time (&sysRTC);
38606 tm_struct = localtime (&sysRTC);
38607 int32_t rval = -1;
38608
38609 switch(type)
38610 {
38611 case curyear:
38612 {
38613 //Year format starts at 1900, yeat
38614 //A raw read of '2018' would be '118', so we add 1900 to it to derive the actual year.
38615 rval = tm_struct->tm_year + 1900; break;
38616
38617 }
38618 case curmonth:
38619 {
38620 //Months start at 0, but we want 1->12
38621 //al_trace("The current month is: %d\n",month);
38622 rval = tm_struct->tm_mon +1; break;
38623 }
38624 case curday_month:
38625 {
38626 rval = tm_struct->tm_mday; break;
38627 }
38628 case curday_week:
38629 {
38630 //It seems that weekdays are a value range of 1 to 7.
38631 rval = tm_struct->tm_wday; break;
38632 }
38633 case curhour:
38634 {
38635 rval = tm_struct->tm_hour; break;
38636 }
38637 case curminute:
38638 {
38639 rval = tm_struct->tm_min; break;
38640 }
38641 case cursecond:
38642 {
38643 rval = tm_struct->tm_sec; break;
38644 }
38645 case curdayyear:
38646 {
38647 //The day (n/365) out of the entire year.
38648 rval = tm_struct->tm_yday; break;
38649 }
38650 case curDST:
38651 {
38652 //Returns if the user is in a Time Zone with Daylight TIme of some sort.
38653 //View the time.h docs for the actual values of this struct element.
38654 rval = tm_struct->tm_isdst;; break;
38655 }
38656 default:
38657 {
38658 al_trace("Invalid category passed to GetSystemTime(%d)\n",type);
38659 rval = -1; break;
38660 }
38661
38662 }
38663 return rval;
38664 }
38665
38666 void FFScript::do_isdeadnpc()
38667 {
38668 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
38669 if(GuyH::loadNPC(ri->guyref, "npc->isDead") == SH::_NoError)
38670 {
38671 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
38672 //int32_t dead = (int32_t)e->Dead(GuyH::getNPCIndex(ri->guyref));
38673 //GuyH::getNPC()->Dead(GuyH::getNPCIndex(ri->guyref));
38674 set_register(sarg1,
38675 ((GuyH::getNPC()->dying && !GuyH::getNPC()->immortal)
38676 ? 10000 : 0));
38677 }
38678 else set_register(sarg1, 0);
38679 }
38680
38681
38682 void FFScript::do_canslidenpc()
38683 {
38684
38685 if(GuyH::loadNPC(ri->guyref, "npc->CanSlide") == SH::_NoError)
38686 {
38687 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
38688 //bool candoit = e->can_slide();
38689 set_register(sarg1, ((GuyH::getNPC()->can_slide()) ? 10000 : 0));
38690 }
38691 else set_register(sarg1, -10000);
38692 }
38693
38694 void FFScript::do_slidenpc()
38695 {
38696
38697 if(GuyH::loadNPC(ri->guyref, "npc->Slide()") == SH::_NoError)
38698 {
38699 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
38700 //bool candoit = e->slide();
38701 set_register(sarg1, ((GuyH::getNPC()->slide())*10000));
38702 }
38703 else set_register(sarg1, -10000);
38704 }
38705
38706 void FFScript::do_npc_stopbgsfx()
38707 {
38708 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
38709 if(GuyH::loadNPC(ri->guyref, "npc->StopBGSFX()") == SH::_NoError)
38710 {
38711 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
38712 //e->stop_bgsfx(GuyH::getNPCIndex(ri->guyref));
38713 GuyH::getNPC()->stop_bgsfx(GuyH::getNPCIndex(ri->guyref));
38714 }
38715 }
38716
38717 void FFScript::do_npc_delete()
38718 {
38719 if(GuyH::loadNPC(ri->guyref, "npc->Remove()") == SH::_NoError)
38720 {
38721 auto ind = GuyH::getNPCIndex(ri->guyref);
38722 GuyH::getNPC()->stop_bgsfx(ind);
38723 guys.del(ind);
38724 }
38725 }
38726
38727 void FFScript::do_lweapon_delete()
38728 {
38729 if(0!=(s=checkLWpn(ri->lwpn,"Remove()")))
38730 {
38731 if(s==Hero.lift_wpn)
38732 {
38733 delete s;
38734 Hero.lift_wpn = nullptr;
38735 }
38736 else Lwpns.del(LwpnH::getLWeaponIndex(ri->lwpn));
38737 }
38738 }
38739
38740 void FFScript::do_eweapon_delete()
38741 {
38742 if(0!=(s=checkEWpn(ri->ewpn,"Remove()")))
38743 {
38744 Ewpns.del(EwpnH::getEWeaponIndex(ri->ewpn));
38745 }
38746 }
38747
38748 8 bool FFScript::do_itemsprite_delete()
38749 {
38750
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(0!=(s=checkItem(ri->itemref)))
38751 {
38752 8 auto ind = ItemH::getItemIndex(ri->itemref);
38753
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!items.del(ind)) return false;
38754
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 8 times.
55 for(int32_t i=0; i<Lwpns.Count(); i++)
38755 {
38756 47 weapon *w = (weapon*)Lwpns.spr(i);
38757
38758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
47 if(w->dragging==ind)
38759 {
38760 w->dragging=-1;
38761 }
38762
1/2
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
47 else if(w->dragging>ind)
38763 {
38764 w->dragging-=1;
38765 }
38766 47 }
38767 8 return true;
38768 }
38769 return false;
38770 8 }
38771
38772 407 void FFScript::updateIncludePaths()
38773 {
38774 407 includePaths.clear();
38775 407 int32_t pos = 0;
38776
2/2
✓ Branch 0 taken 1221 times.
✓ Branch 1 taken 407 times.
1628 for ( int32_t q = 0; includePathString[pos]; ++q )
38777 {
38778 1221 int32_t dest = 0;
38779 1221 char buf[2048] = {0};
38780
4/4
✓ Branch 0 taken 1221 times.
✓ Branch 1 taken 9768 times.
✓ Branch 2 taken 9768 times.
✓ Branch 3 taken 1221 times.
10989 while(includePathString[pos] != ';' && includePathString[pos])
38781 {
38782 9768 buf[dest] = includePathString[pos];
38783 9768 ++pos;
38784 9768 ++dest;
38785 }
38786 1221 ++pos;
38787
1/2
✓ Branch 0 taken 1221 times.
✗ Branch 1 not taken.
1221 std::string str(buf);
38788
1/2
✓ Branch 0 taken 1221 times.
✗ Branch 1 not taken.
1221 includePaths.push_back(str);
38789 1221 }
38790 407 }
38791
38792 407 void FFScript::initRunString()
38793 {
38794 407 memset(scriptRunString,0,sizeof(scriptRunString));
38795 407 strcpy(scriptRunString,zc_get_config("Compiler","run_string","run",App::zscript));
38796 407 }
38797
38798 407 void FFScript::initIncludePaths()
38799 {
38800 407 memset(includePathString,0,sizeof(includePathString));
38801 407 FILE* f = fopen("includepaths.txt", "r");
38802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 407 times.
407 if(f)
38803 {
38804 int32_t pos = 0;
38805 int32_t c;
38806 do
38807 {
38808 c = fgetc(f);
38809 if(c!=EOF)
38810 includePathString[pos++] = c;
38811 }
38812 while(c!=EOF && pos<MAX_INCLUDE_PATH_CHARS);
38813 if(pos<MAX_INCLUDE_PATH_CHARS)
38814 includePathString[pos] = '\0';
38815 includePathString[MAX_INCLUDE_PATH_CHARS-1] = '\0';
38816 fclose(f);
38817 }
38818 407 else strcpy(includePathString, "include/;headers/;scripts/;");
38819 407 al_trace("Full path string is: ");
38820 407 safe_al_trace(includePathString);
38821 407 al_trace("\n");
38822 407 updateIncludePaths();
38823
38824
2/2
✓ Branch 0 taken 1221 times.
✓ Branch 1 taken 407 times.
1628 for ( size_t q = 0; q < includePaths.size(); ++q )
38825 {
38826 1221 al_trace("Include path %zu: ",q);
38827 1221 safe_al_trace(includePaths.at(q));
38828 1221 al_trace("\n");
38829 1221 }
38830 407 }
38831
38832 void FFScript::do_npcattack()
38833 {
38834
38835 if(GuyH::loadNPC(ri->guyref, "npc->Attack()") == SH::_NoError)
38836 {
38837 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
38838 //e->FireWeapon();
38839 //we could just do:
38840 GuyH::getNPC()->FireWeapon();
38841 }
38842 }
38843 void FFScript::do_npc_newdir()
38844 {
38845 int32_t arrayptr = get_register(sarg1) / 10000;
38846 ArrayManager am(arrayptr);
38847 if(am.invalid()) return;
38848 int32_t sz = am.size();
38849
38850 if(GuyH::loadNPC(ri->guyref, "npc->NewDir()") == SH::_NoError)
38851 {
38852 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
38853
38854 if ( sz != -1 )
38855 {
38856 if ( sz != 3 )
38857 {
38858 Z_scripterrlog("Invalid array size (%d) passed to npc->VariableWalk(int32_t arr[])\n",sz);
38859 return;
38860 }
38861 GuyH::getNPC()->newdir((am.get(0)/10000), (am.get(1)/10000),
38862 (am.get(2)/10000));
38863 }
38864 //else e->newdir();
38865 else GuyH::getNPC()->newdir();
38866 }
38867 }
38868
38869 void FFScript::do_npc_constwalk()
38870 {
38871 int32_t arrayptr = get_register(sarg1) / 10000;
38872 ArrayManager am(arrayptr);
38873 if(am.invalid()) return;
38874 int32_t sz = am.size();
38875
38876 if(GuyH::loadNPC(ri->guyref, "npc->ConstantWalk()") == SH::_NoError)
38877 {
38878 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
38879
38880 if ( sz != -1 )
38881 {
38882 if ( sz != 3 )
38883 {
38884 Z_scripterrlog("Invalid array size (%d) passed to npc->VariableWalk(int32_t arr[])\n",sz);
38885 return;
38886 }
38887 GuyH::getNPC()->constant_walk( (am.get(0)/10000), (am.get(1)/10000),
38888 (am.get(2)/10000) );
38889 }
38890 else GuyH::getNPC()->constant_walk();//e->constant_walk();
38891 }
38892 }
38893
38894 void FFScript::do_npc_varwalk()
38895 {
38896 int32_t arrayptr = get_register(sarg2) / 10000;
38897 ArrayManager am(arrayptr);
38898 if(am.invalid()) return;
38899 int32_t sz = am.size();
38900
38901 if(GuyH::loadNPC(ri->guyref, "npc->VariableWalk()") == SH::_NoError)
38902 {
38903 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
38904
38905 if ( sz == 3 )
38906 {
38907
38908 GuyH::getNPC()->variable_walk( (am.get(0)/10000), (am.get(1)/10000),
38909 (am.get(2)/10000) );
38910 }
38911 else Z_scripterrlog("Invalid array size (%d) passed to npc->VariableWalk(int32_t arr[])\n",sz);
38912 }
38913 }
38914
38915 void FFScript::do_npc_varwalk8()
38916 {
38917 int32_t arrayptr = get_register(sarg1) / 10000;
38918 ArrayManager am(arrayptr);
38919 if(am.invalid()) return;
38920 int32_t sz = am.size();
38921
38922 if(GuyH::loadNPC(ri->guyref, "npc->VariableWalk8()") == SH::_NoError)
38923 {
38924 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
38925
38926 if ( sz == 4 )
38927 {
38928 GuyH::getNPC()->variable_walk_8( (am.get(0)/10000), (am.get(1)/10000),
38929 (am.get(2)/10000), (am.get(3)/10000) );
38930 }
38931 else if ( sz == 8 )
38932 {
38933 GuyH::getNPC()->variable_walk_8( (am.get(0)/10000), (am.get(1)/10000),
38934 (am.get(2)/10000), (am.get(3)/10000),
38935 (am.get(4)/10000), (am.get(5)/10000),
38936 (am.get(6)/10000), (am.get(7)/10000)
38937 );
38938 }
38939 else Z_scripterrlog("Invalid array size (%d) passed to npc->VariableWalk(int32_t arr[])\n",sz);
38940 }
38941 }
38942
38943 void FFScript::do_npc_constwalk8()
38944 {
38945 int32_t arrayptr = get_register(sarg1) / 10000;
38946 ArrayManager am(arrayptr);
38947 if(am.invalid()) return;
38948 int32_t sz = am.size();
38949
38950 if(GuyH::loadNPC(ri->guyref, "npc->ConstantWalk8()") == SH::_NoError)
38951 {
38952 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
38953
38954 if ( sz == 3 )
38955 {
38956 GuyH::getNPC()->constant_walk_8( (am.get(0)/10000), (am.get(1)/10000),
38957 (am.get(2)/10000) );
38958 }
38959
38960 else Z_scripterrlog("Invalid array size (%d) passed to npc->VariableWalk(int32_t arr[])\n",sz);
38961 }
38962 }
38963
38964
38965 void FFScript::do_npc_haltwalk()
38966 {
38967 int32_t arrayptr = get_register(sarg1) / 10000;
38968 ArrayManager am(arrayptr);
38969 if(am.invalid()) return;
38970 int32_t sz = am.size();
38971
38972 if(GuyH::loadNPC(ri->guyref, "npc->HaltingWalk()") == SH::_NoError)
38973 {
38974 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
38975
38976 if ( sz == 5 )
38977 {
38978 GuyH::getNPC()->halting_walk( (am.get(0)/10000), (am.get(1)/10000),
38979 (am.get(2)/10000), (am.get(3)/10000),
38980 (am.get(4)/10000));
38981 }
38982 else Z_scripterrlog("Invalid array size (%d) passed to npc->VariableWalk(int32_t arr[])\n",sz);
38983 }
38984 }
38985
38986 void FFScript::do_npc_haltwalk8()
38987 {
38988 int32_t arrayptr = get_register(sarg1) / 10000;
38989 ArrayManager am(arrayptr);
38990 if(am.invalid()) return;
38991 int32_t sz = am.size();
38992
38993 if(GuyH::loadNPC(ri->guyref, "npc->HaltingWalk8()") == SH::_NoError)
38994 {
38995 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
38996
38997 if ( sz == 6 )
38998 {
38999
39000 GuyH::getNPC()->halting_walk_8( (am.get(0)/10000), (am.get(1)/10000),
39001 (am.get(2)/10000), (am.get(3)/10000),
39002 (am.get(4)/10000),(am.get(5)/10000));
39003 }
39004 else Z_scripterrlog("Invalid array size (%d) passed to npc->VariableWalk(int32_t arr[])\n",sz);
39005 }
39006 }
39007
39008
39009 void FFScript::do_npc_floatwalk()
39010 {
39011 int32_t arrayptr = get_register(sarg1) / 10000;
39012 ArrayManager am(arrayptr);
39013 if(am.invalid()) return;
39014 int32_t sz = am.size();
39015
39016 if(GuyH::loadNPC(ri->guyref, "npc->FloatingWalk()") == SH::_NoError)
39017 {
39018 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
39019
39020 if ( sz == 3 )
39021 {
39022
39023 GuyH::getNPC()->floater_walk( (am.get(0)/10000), (am.get(1)/10000),
39024 (zfix)(am.get(2)/10000));
39025
39026 }
39027 else if ( sz == 7 )
39028 {
39029
39030 GuyH::getNPC()->floater_walk( (am.get(0)/10000), (am.get(1)/10000),
39031 (zfix)(am.get(2)/10000), (zfix)(am.get(3)/10000),
39032 (am.get(4)/10000),(am.get(5)/10000),
39033 (am.get(6)/10000));
39034 }
39035 else Z_scripterrlog("Invalid array size (%d) passed to npc->VariableWalk(int32_t arr[])\n",sz);
39036 }
39037 }
39038
39039 void FFScript::do_npc_breathefire()
39040 {
39041 bool seek = (get_register(sarg1));
39042 if(GuyH::loadNPC(ri->guyref, "npc->BreathAttack()") == SH::_NoError)
39043 {
39044 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
39045 GuyH::getNPC()->FireBreath(seek);
39046
39047 }
39048 }
39049
39050
39051 void FFScript::do_npc_newdir8()
39052 {
39053 int32_t arrayptr = get_register(sarg1) / 10000;
39054 ArrayManager am(arrayptr);
39055 if(am.invalid()) return;
39056 int32_t sz = am.size();
39057
39058 if(GuyH::loadNPC(ri->guyref, "npc->NewDir8()") == SH::_NoError)
39059 {
39060 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
39061
39062 if ( sz == 3 )
39063 {
39064
39065 GuyH::getNPC()->newdir_8( (am.get(0)/10000), (am.get(1)/10000),
39066 (am.get(2)/10000));
39067
39068 }
39069 else if ( sz == 7 )
39070 {
39071
39072 GuyH::getNPC()->newdir_8( (am.get(0)/10000), (am.get(1)/10000),
39073 (am.get(2)/10000), (am.get(3)/10000),
39074 (am.get(4)/10000),(am.get(5)/10000),
39075 (am.get(6)/10000));
39076 }
39077 else Z_scripterrlog("Invalid array size (%d) passed to npc->VariableWalk(int32_t arr[])\n",sz);
39078 }
39079 }
39080
39081
39082 int32_t FFScript::npc_collision()
39083 {
39084 int32_t isColl = 0;
39085 if(GuyH::loadNPC(ri->guyref, "npc->Collision()") == SH::_NoError)
39086 {
39087 int32_t _obj_type = (ri->d[rINDEX] / 10000);
39088 int32_t _obj_ptr = (ri->d[rINDEX2]);
39089
39090 switch(_obj_type)
39091 {
39092 case obj_type_lweapon:
39093 {
39094 isColl = 0;
39095 break;
39096 }
39097 case obj_type_eweapon:
39098 {
39099 isColl = 0;
39100 break;
39101 }
39102 case obj_type_npc:
39103 {
39104 isColl = 0;
39105 break;
39106 }
39107 case obj_type_player:
39108 {
39109 isColl = 0;
39110 break;
39111 }
39112 case obj_type_ffc:
39113 {
39114 _obj_ptr *= 10000; _obj_ptr -= 1;
39115 isColl = 0;
39116 break;
39117 }
39118 case obj_type_combo_pos:
39119 {
39120 _obj_ptr *= 10000;
39121 isColl = 0;
39122 break;
39123 }
39124 case obj_type_item:
39125 {
39126 isColl = 0;
39127 break;
39128 }
39129 default:
39130 {
39131 Z_scripterrlog("Invalid object type (%d) passed to npc->Collision(int32_t type, int32_t ptr)\n", _obj_type);
39132 isColl = 0;
39133 break;
39134 }
39135 }
39136 }
39137
39138 return isColl;
39139 }
39140
39141
39142 int32_t FFScript::npc_linedup()
39143 {
39144 if(GuyH::loadNPC(ri->guyref, "npc->LinedUp()") == SH::_NoError)
39145 {
39146 int32_t range = (ri->d[rINDEX] / 10000);
39147 bool dir8 = (ri->d[rINDEX2]);
39148 return (int32_t)(GuyH::getNPC()->lined_up(range,dir8)*10000);
39149 }
39150
39151 return 0;
39152 }
39153
39154
39155 void FFScript::do_npc_hero_in_range(const bool v)
39156 {
39157 int32_t dist = get_register(sarg1) / 10000;
39158 if(GuyH::loadNPC(ri->guyref, "npc->LinedUp()") == SH::_NoError)
39159 {
39160 bool in_range = GuyH::getNPC()->HeroInRange(dist);
39161 set_register(sarg1, (in_range ? 10000 : 0)); //This isn't setting the right value, it seems.
39162 }
39163 else set_register(sarg2, 0);
39164 }
39165
39166
39167
39168
39169
39170
39171 void FFScript::do_npc_simulate_hit(const bool v)
39172 {
39173 int32_t arrayptr = SH::get_arg(sarg1, v) / 10000;
39174 ArrayManager am(arrayptr);
39175 if(am.invalid()) return;
39176 int32_t sz = am.size();
39177 bool ishit = false;
39178
39179 if(GuyH::loadNPC(ri->guyref, "npc->SimulateHit()") == SH::_NoError)
39180 {
39181 // zprint("Trying to simulate a hit on npc\n");
39182 //enemy *e = (enemy*)guys.spr(GuyH::getNPCIndex(ri->guyref));
39183 if ( sz == 2 ) //type and pointer
39184 {
39185 // int32_t type = am.get(0)/10000;
39186
39187 //switch(type)
39188 //{
39189 // case simulate_hit_type_weapon:
39190 // {
39191 // ishit = e->hit(*);
39192 // break;
39193 // }
39194 // case simulate_hit_type_sprite:
39195 // {
39196 // ishit = e->hit(*);
39197 // break;
39198 // }
39199 //}
39200 ishit = false;
39201 }
39202 if ( sz == 6 ) //hit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz);
39203 {
39204 ishit = GuyH::getNPC()->hit( (am.get(0)/10000), (am.get(1)/10000),
39205 (am.get(2)/10000), (am.get(3)/10000),
39206 (am.get(4)/10000), (am.get(5)/10000) );
39207
39208 }
39209 else
39210 {
39211 Z_scripterrlog("Invalid array size (%d) passed to npc->SimulateHit(). The array size must be [1] or [3].\n", sz);
39212 ishit = false;
39213 }
39214 }
39215 set_register(sarg1, ( ishit ? 10000 : 0));
39216 }
39217
39218 void FFScript::do_npc_knockback(const bool v)
39219 {
39220 int32_t time = SH::get_arg(sarg1, v) / 10000;
39221 int32_t dir = SH::get_arg(sarg2, v) / 10000;
39222 int32_t spd = vbound(ri->d[rINDEX] / 10000, 0, 255);
39223 //zprint("Knockback: time %d,dir %d,spd %d\n",time,dir,spd);
39224 bool ret = false;
39225
39226 if(GuyH::loadNPC(ri->guyref, "npc->Knockback()") == SH::_NoError)
39227 {
39228 ret = GuyH::getNPC()->knockback(time, dir, spd);
39229 }
39230 set_register(sarg1, ( ret ? 10000 : 0));
39231 }
39232
39233 void FFScript::do_npc_add(const bool v)
39234 {
39235
39236 int32_t arrayptr = SH::get_arg(sarg1, v) / 10000;
39237 ArrayManager am(arrayptr);
39238 if(am.invalid()) return;
39239 int32_t sz = am.size();
39240
39241 int32_t id = 0, nx = 0, ny = 0;
39242
39243 if ( sz < 1 )
39244 {
39245 Z_scripterrlog("Invalid array size (%d) passed to npc->Create(). The array size must be [1] or [3].\n", sz);
39246 return;
39247 }
39248 else //size is valid
39249 {
39250 id = (am.get(0)/10000);
39251
39252 if ( sz == 3 ) //x and y
39253 {
39254 nx = (am.get(1)/10000);
39255 ny = (am.get(2)/10000);
39256 }
39257 }
39258
39259
39260 if(BC::checkGuyID(id, "npc->Create()") != SH::_NoError)
39261 return;
39262
39263 //If we make a segmented enemy there'll be more than one sprite created
39264 word numcreated = addenemy(nx, ny, id, -10);
39265
39266 if(numcreated == 0)
39267 {
39268 ri->guyref = MAX_DWORD;
39269 Z_scripterrlog("Couldn't create NPC \"%s\", screen NPC limit reached\n", guy_string[id]);
39270 }
39271 else
39272 {
39273 word index = guys.Count() - numcreated; //Get the main enemy, not a segment
39274 ri->guyref = guys.spr(index)->getUID();
39275
39276 for(; index<guys.Count(); index++)
39277 ((enemy*)guys.spr(index))->script_spawned=true;
39278
39279 ri->d[rEXP1] = ri->guyref;
39280 ri->d[rEXP2] = ri->guyref;
39281 Z_eventlog("Script created NPC \"%s\" with UID = %ld\n", guy_string[id], ri->guyref);
39282 }
39283 }
39284
39285 bool FFScript::checkExtension(std::string &filename, const std::string &extension)
39286 //inline bool checkExtension(std::string filename, std::string extension)
39287 {
39288 int32_t dot = filename.find_last_of(".");
39289 std::string exten = (dot == std::string::npos ? "" : filename.substr(dot, filename.length() - dot));
39290 return exten == extension;
39291 }
39292
39293
39294 void FFScript::do_loadgamestructs(const bool v, const bool v2)
39295 {
39296 int32_t arrayptr = SH::get_arg(sarg1, v) / 10000;
39297 int32_t section_id = SH::get_arg(sarg2, v2) / 10000;
39298 zprint("do_loadgamestructs selected section is: %d\n", section_id);
39299 //Bitwise OR sections together
39300 string strA;
39301 ArrayH::getString(arrayptr, strA, 256);
39302 int32_t temp_sram_flags = section_id; int32_t sram_version = 0;
39303
39304 if ( FFCore.checkExtension(strA, ".zcsram") )
39305 {
39306 PACKFILE *f = pack_fopen_password(strA.c_str(),F_READ, "");
39307 if (f)
39308 {
39309 p_igetl(&sram_version,f);
39310 p_igetl(&section_id,f);
39311 zprint("Reading ZCSRAM, Version: %d\n", sram_version);
39312 if ( sram_version > SRAM_VERSION ) //file version is greater than programme current version.
39313 {
39314 Z_scripterrlog("SRAM Version is from a version of ZC newer than the running version and cannot be loaded.\n");
39315 return;
39316 }
39317 if ( section_id != temp_sram_flags )
39318 {
39319 Z_scripterrlog("Reading an SRAM file with a section flag mismatch!\nThe file section flags are (%d) and the specified flagset is (%d).\nThis may cause errors!\n", section_id, temp_sram_flags);
39320 }
39321
39322 if ( !section_id || section_id&svGUYS ) FFCore.read_enemies(f,sram_version);
39323 if ( !section_id || section_id&svITEMS )FFCore.read_items(f,sram_version);
39324 if ( !section_id || section_id&svWEAPONS ) FFCore.read_weaponsprtites(f,sram_version);
39325 if ( !section_id || section_id&svCOMBOS )
39326 {
39327 reset_combo_animations();
39328 reset_combo_animations2();
39329 FFCore.read_combos(f,sram_version);
39330 }
39331 if ( !section_id || section_id&svDMAPS ) FFCore.read_dmaps(f,sram_version);
39332 if ( !section_id || section_id&svMAPSCR ) FFCore.read_mapscreens(f,sram_version);
39333 pack_fclose(f);
39334 zprint("do_savegamestructs COMPLETED READINV %s, with section ID flags %d\n", "ALL", section_id);
39335
39336 set_register(sarg1, 10000);
39337 }
39338 else
39339 {
39340 Z_scripterrlog("FFCore.do_loadgamestructs could not read packfile!");
39341 set_register(sarg1, -10000);
39342 }
39343 }
39344 else
39345 {
39346 Z_scripterrlog("Tried to read a .zcsram file, but the file lacked the ..zcsram extension!\n");
39347 set_register(sarg1, -20000);
39348
39349 }
39350 }
39351
39352 void FFScript::do_savegamestructs(const bool v, const bool v2)
39353 {
39354 int32_t arrayptr = SH::get_arg(sarg1, v) / 10000;
39355 int32_t section_id = SH::get_arg(sarg2, v2) / 10000;
39356 zprint("do_loadgamestructs selected section is: %d\n", section_id);
39357 //Bitwise OR sections together
39358 string strA;
39359 ArrayH::getString(arrayptr, strA, 256);
39360 int32_t cycles = 0;
39361
39362 if ( FFCore.checkExtension(strA, ".zcsram") )
39363 {
39364 PACKFILE *f = pack_fopen_password(strA.c_str(),F_WRITE, "");
39365 if (f)
39366 {
39367 p_iputl(SRAM_VERSION,f);
39368 p_iputl(section_id,f);
39369
39370 if ( !section_id || section_id&svGUYS ) FFCore.write_enemies(f,SRAM_VERSION);
39371 if ( !section_id || section_id&svITEMS ) FFCore.write_items(f,SRAM_VERSION);
39372 if ( !section_id || section_id&svWEAPONS ) FFCore.write_weaponsprtites(f,SRAM_VERSION);
39373 if ( !section_id || section_id&svCOMBOS )
39374 {
39375 reset_combo_animations();
39376 reset_combo_animations2();
39377 FFCore.write_combos(f,SRAM_VERSION);
39378 }
39379 if ( !section_id || section_id&svDMAPS ) FFCore.write_dmaps(f,SRAM_VERSION);
39380 if ( !section_id || section_id&svMAPSCR ) FFCore.write_mapscreens(f,SRAM_VERSION);
39381 pack_fclose(f);
39382 zprint("do_savegamestructs COMPLETED WRITING %s, with section ID flags %d\n", "ALL", section_id);
39383 set_register(sarg1, 10000);
39384 }
39385 else
39386 {
39387 Z_scripterrlog("FFCore.do_loadgamestructs could not read packfile!");
39388 set_register(sarg1, -10000);
39389 }
39390 }
39391 else
39392 {
39393 Z_scripterrlog("Tried to write a .zcsram file, but the file lacked the ..zcsram extension!\n");
39394 set_register(sarg1, -20000);
39395 }
39396 }
39397
39398 1 void FFScript::do_strcmp()
39399 {
39400 1 int32_t arrayptr_a = ri->d[rINDEX]/10000; //get_register(sarg1) / 10000 ?
39401 1 int32_t arrayptr_b = ri->d[rINDEX2]/10000; //get_register(sarg2) / 10000?
39402 1 string strA;
39403 1 string strB;
39404
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 ArrayH::getString(arrayptr_a, strA);
39405
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 ArrayH::getString(arrayptr_b, strB);
39406
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 set_register(sarg1, (strcmp(strA.c_str(), strB.c_str()) * 10000));
39407 1 }
39408
39409 void FFScript::do_stricmp()
39410 {
39411 int32_t arrayptr_a = ri->d[rINDEX]/10000; //get_register(sarg1) / 10000? Index and Index2 are intentional.
39412 int32_t arrayptr_b = ri->d[rINDEX2]/10000; //get_register(sarg2) / 10000?
39413 string strA;
39414 string strB;
39415 ArrayH::getString(arrayptr_a, strA);
39416 ArrayH::getString(arrayptr_b, strB);
39417 set_register(sarg1, (stricmp(strA.c_str(), strB.c_str()) * 10000));
39418 }
39419
39420 1 void FFScript::do_LowerToUpper(const bool v)
39421 {
39422
39423 1 int32_t arrayptr_a = get_register(sarg1) / 10000;
39424 1 string strA;
39425
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 ArrayH::getString(arrayptr_a, strA);
39426
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( strA.size() < 1 )
39427 {
39428 Z_scripterrlog("String passed to UpperToLower() is too small. Size is: %d \n", strA.size());
39429 set_register(sarg1, 0); return;
39430 }
39431
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 5 times.
6 for ( size_t q = 0; q < strA.size(); ++q )
39432 {
39433
3/8
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 5 times.
✗ Branch 7 not taken.
5 strA[q] -= 32 * (strA[q] >= 'a' && strA[q] <= 'z');
39434 //if(( strA[q] >= 'a' && strA[q] <= 'z' ) || ( strA[q] >= 'A' && strA[q] <= 'Z' ))
39435 //{
39436 // if ( strA[q] < 'a' ) { continue; }
39437 // else strA[q] -= 32;
39438 // continue;
39439 //}
39440
39441 5 }
39442 //zprint("Converted string is: %s \n", strA.c_str());
39443
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(ArrayH::setArray(arrayptr_a, strA) == SH::_Overflow)
39444 {
39445 Z_scripterrlog("Dest string supplied to 'LowerToUpper()' not large enough\n");
39446 set_register(sarg1, 0);
39447 }
39448
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 else set_register(sarg1, (10000));
39449
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 }
39450
39451 void FFScript::do_UpperToLower(const bool v)
39452 {
39453
39454 int32_t arrayptr_a = get_register(sarg1) / 10000;
39455 string strA;
39456 ArrayH::getString(arrayptr_a, strA);
39457 if ( strA.size() < 1 )
39458 {
39459 Z_scripterrlog("String passed to UpperToLower() is too small. Size is: %d \n", strA.size());
39460 set_register(sarg1, 0); return;
39461 }
39462 for ( size_t q = 0; q < strA.size(); ++q )
39463 {
39464 strA[q] += 32 * (strA[q] >= 'A' && strA[q] <= 'Z');
39465 //if(( strA[q] >= 'a' && strA[q] <= 'z' ) || ( strA[q] >= 'A' && strA[q] <= 'Z' ))
39466 //{
39467 // if ( strA[q] < 'a' ) { strA[q] += 32; }
39468 // else continue;
39469 // continue;
39470 //}
39471 }
39472 //zprint("Converted string is: %s \n", strA.c_str());
39473 if(ArrayH::setArray(arrayptr_a, strA) == SH::_Overflow)
39474 {
39475 Z_scripterrlog("Dest string supplied to 'LowerToUpper()' not large enough\n");
39476 set_register(sarg1, 0);
39477 }
39478 else set_register(sarg1, (10000));
39479 }
39480
39481 void FFScript::do_getnpcscript()
39482 {
39483 int32_t arrayptr = get_register(sarg1) / 10000;
39484 string the_string;
39485 int32_t script_num = -1;
39486 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
39487
39488 for(int32_t q = 0; q < NUMSCRIPTGUYS; q++)
39489 {
39490 if(!(strcmp(the_string.c_str(), npcmap[q].scriptname.c_str())))
39491 {
39492 script_num = q+1;
39493 break;
39494 }
39495 }
39496 set_register(sarg1, (script_num * 10000));
39497 }
39498
39499 void FFScript::do_getcomboscript()
39500 {
39501 int32_t arrayptr = get_register(sarg1) / 10000;
39502 string the_string;
39503 int32_t script_num = -1;
39504 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
39505
39506 for(int32_t q = 0; q < NUMSCRIPTSCOMBODATA; q++)
39507 {
39508 if(!(strcmp(the_string.c_str(), comboscriptmap[q].scriptname.c_str())))
39509 {
39510 script_num = q+1;
39511 break;
39512 }
39513 }
39514 set_register(sarg1, (script_num * 10000));
39515 }
39516
39517 68 void FFScript::do_getgenericscript()
39518 {
39519 68 int32_t arrayptr = get_register(sarg1) / 10000;
39520 68 string the_string;
39521 68 int32_t script_num = -1;
39522
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
39523
39524 // zprint2("Searching for generic script named '%s'\n", the_string.c_str());
39525
1/2
✓ Branch 0 taken 361 times.
✗ Branch 1 not taken.
361 for(int32_t q = 0; q < NUMSCRIPTSGENERIC; q++)
39526 {
39527 // if(genericmap[q].scriptname.size()>2)
39528 // zprint2("Checking against '%s'...\n", genericmap[q].scriptname.c_str());
39529
3/4
✓ Branch 0 taken 361 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 293 times.
✓ Branch 3 taken 68 times.
361 if(!(strcmp(the_string.c_str(), genericmap[q].scriptname.c_str())))
39530 {
39531 68 script_num = q+1;
39532 68 break;
39533 }
39534 293 }
39535
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 set_register(sarg1, (script_num * 10000));
39536 68 }
39537
39538 586 void FFScript::do_getlweaponscript()
39539 {
39540 586 int32_t arrayptr = get_register(sarg1) / 10000;
39541 586 string the_string;
39542 586 int32_t script_num = -1;
39543
1/2
✓ Branch 0 taken 586 times.
✗ Branch 1 not taken.
586 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
39544
39545
1/2
✓ Branch 0 taken 17245 times.
✗ Branch 1 not taken.
17245 for(int32_t q = 0; q < NUMSCRIPTWEAPONS; q++)
39546 {
39547
3/4
✓ Branch 0 taken 17245 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16659 times.
✓ Branch 3 taken 586 times.
17245 if(!(strcmp(the_string.c_str(), lwpnmap[q].scriptname.c_str())))
39548 {
39549 586 script_num = q+1;
39550 586 break;
39551 }
39552 16659 }
39553
1/2
✓ Branch 0 taken 586 times.
✗ Branch 1 not taken.
586 set_register(sarg1, (script_num * 10000));
39554 586 }
39555 1275 void FFScript::do_geteweaponscript()
39556 {
39557 1275 int32_t arrayptr = get_register(sarg1) / 10000;
39558 1275 string the_string;
39559 1275 int32_t script_num = -1;
39560
1/2
✓ Branch 0 taken 1275 times.
✗ Branch 1 not taken.
1275 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
39561
39562
1/2
✓ Branch 0 taken 29109 times.
✗ Branch 1 not taken.
29109 for(int32_t q = 0; q < NUMSCRIPTWEAPONS; q++)
39563 {
39564
3/4
✓ Branch 0 taken 29109 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27834 times.
✓ Branch 3 taken 1275 times.
29109 if(!(strcmp(the_string.c_str(), ewpnmap[q].scriptname.c_str())))
39565 {
39566 1275 script_num = q+1;
39567 1275 break;
39568 }
39569 27834 }
39570
1/2
✓ Branch 0 taken 1275 times.
✗ Branch 1 not taken.
1275 set_register(sarg1, (script_num * 10000));
39571 1275 }
39572 void FFScript::do_getheroscript()
39573 {
39574 int32_t arrayptr = get_register(sarg1) / 10000;
39575 string the_string;
39576 int32_t script_num = -1;
39577 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
39578
39579 for(int32_t q = 0; q < NUMSCRIPTPLAYER; q++)
39580 {
39581 if(!(strcmp(the_string.c_str(), playermap[q].scriptname.c_str())))
39582 {
39583 script_num = q+1;
39584 break;
39585 }
39586 }
39587 set_register(sarg1, (script_num * 10000));
39588 }
39589 void FFScript::do_getglobalscript()
39590 {
39591 int32_t arrayptr = get_register(sarg1) / 10000;
39592 string the_string;
39593 int32_t script_num = -1;
39594 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
39595
39596 for(int32_t q = 0; q < NUMSCRIPTGLOBAL; q++)
39597 {
39598 if(!(strcmp(the_string.c_str(), globalmap[q].scriptname.c_str())))
39599 {
39600 script_num = q+1;
39601 break;
39602 }
39603 }
39604 set_register(sarg1, (script_num * 10000));
39605 }
39606 102 void FFScript::do_getdmapscript()
39607 {
39608 102 int32_t arrayptr = get_register(sarg1) / 10000;
39609 102 string the_string;
39610 102 int32_t script_num = -1;
39611
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
39612
39613
1/2
✓ Branch 0 taken 575 times.
✗ Branch 1 not taken.
575 for(int32_t q = 0; q < NUMSCRIPTSDMAP; q++)
39614 {
39615
3/4
✓ Branch 0 taken 575 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 473 times.
✓ Branch 3 taken 102 times.
575 if(!(strcmp(the_string.c_str(), dmapmap[q].scriptname.c_str())))
39616 {
39617 102 script_num = q+1;
39618 102 break;
39619 }
39620 473 }
39621
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 set_register(sarg1, (script_num * 10000));
39622 102 }
39623 void FFScript::do_getscreenscript()
39624 {
39625 int32_t arrayptr = get_register(sarg1) / 10000;
39626 string the_string;
39627 int32_t script_num = -1;
39628 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
39629
39630 for(int32_t q = 0; q < NUMSCRIPTSCREEN; q++)
39631 {
39632 if(!(strcmp(the_string.c_str(), screenmap[q].scriptname.c_str())))
39633 {
39634 script_num = q+1;
39635 break;
39636 }
39637 }
39638 set_register(sarg1, (script_num * 10000));
39639 }
39640 31 void FFScript::do_getitemspritescript()
39641 {
39642 31 int32_t arrayptr = get_register(sarg1) / 10000;
39643 31 string the_string;
39644 31 int32_t script_num = -1;
39645
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
39646
39647
1/2
✓ Branch 0 taken 273 times.
✗ Branch 1 not taken.
273 for(int32_t q = 0; q < NUMSCRIPTSITEMSPRITE; q++)
39648 {
39649
3/4
✓ Branch 0 taken 273 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 242 times.
✓ Branch 3 taken 31 times.
273 if(!(strcmp(the_string.c_str(), itemspritemap[q].scriptname.c_str())))
39650 {
39651 31 script_num = q+1;
39652 31 break;
39653 }
39654 242 }
39655
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 set_register(sarg1, (script_num * 10000));
39656 31 }
39657 //Not assigned to slots at present. If they ever are, then this would get the id of any script (any type) by name. -Z
39658 void FFScript::do_getuntypedscript()
39659 {
39660 set_register(sarg1, 0);
39661 //int32_t arrayptr = ri->d[rINDEX]/10000;
39662 //string the_string;
39663 //int32_t script_num = -1;
39664 //ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
39665
39666 //for(int32_t q = 0; q < NUMSCRIPTSITEMSPRITE; q++)
39667 //{
39668 // if(!(strcmp(the_string.c_str(), itemspritemap[q].scriptname.c_str())))
39669 // {
39670 // script_num = q+1;
39671 // break;
39672 // }
39673 //}
39674 //set_register(sarg1, (script_num * 10000));
39675 }
39676 void FFScript::do_getsubscreenscript()
39677 {
39678 //int32_t arrayptr = ri->d[rINDEX]/10000;
39679 //string the_string;
39680 //int32_t script_num = -1;
39681 //ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
39682
39683 //for(int32_t q = 0; q < NUMSCRIPTSUBSCREEN; q++)
39684 //{
39685 // if(!(strcmp(the_string.c_str(), subscreenmap[q].scriptname.c_str())))
39686 // {
39687 // script_num = q+1;
39688 // break;
39689 // }
39690 //}
39691 //set_register(sarg1, (script_num * 10000));
39692 set_register(sarg1, 0); //Remove this line, when we add this script type, then un-comment the rest. -Z
39693 }
39694 void FFScript::do_getnpcbyname()
39695 {
39696 int32_t arrayptr = get_register(sarg1) / 10000;
39697 string the_string;
39698 int32_t num = -1;
39699 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
39700
39701 for(int32_t q = 0; q < MAXNPCS; q++)
39702 {
39703 if(!(strcmp(the_string.c_str(), guy_string[q])))
39704 {
39705 num = q;
39706 break;
39707 }
39708 }
39709 set_register(sarg1, (num * 10000));
39710 }
39711 void FFScript::do_getitembyname()
39712 {
39713 int32_t arrayptr = get_register(sarg1) / 10000;
39714 string the_string;
39715 int32_t num = -1;
39716 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
39717
39718 for(int32_t q = 0; q < MAXNPCS; q++)
39719 {
39720 if(!(strcmp(the_string.c_str(), item_string[q])))
39721 {
39722 num = q;
39723 break;
39724 }
39725 }
39726 set_register(sarg1, (num * 10000));
39727 }
39728 void FFScript::do_getcombobyname()
39729 {
39730 int32_t arrayptr = get_register(sarg1) / 10000;
39731 string the_string;
39732 int32_t num = -1;
39733 ArrayH::getString(arrayptr, the_string, 256);
39734
39735 if (!the_string.empty())
39736 {
39737 for(int32_t q = 0; q < MAXCOMBOS; q++)
39738 {
39739 if (the_string == combobuf[q].label)
39740 {
39741 num = q;
39742 break;
39743 }
39744 }
39745 }
39746 set_register(sarg1, (num * 10000));
39747 }
39748 void FFScript::do_getdmapbyname()
39749 {
39750 int32_t arrayptr = get_register(sarg1) / 10000;
39751 string the_string;
39752 int32_t num = -1;
39753 ArrayH::getString(arrayptr, the_string, 256); //What is the max length of a script identifier?
39754
39755 for(int32_t q = 0; q < MAXNPCS; q++)
39756 {
39757 if(!(strcmp(the_string.c_str(), DMaps[q].title)))
39758 {
39759 num = q;
39760 break;
39761 }
39762 }
39763 set_register(sarg1, (num * 10000));
39764 }
39765
39766 ////////////////////////
39767 /// String Utilities ///
39768 ////////////////////////
39769 void FFScript::do_ConvertCase(const bool v)
39770 {
39771 int32_t arrayptr_a = get_register(sarg1) / 10000;
39772 string strA;
39773 ArrayH::getString(arrayptr_a, strA);
39774 if ( strA.size() < 1 )
39775 {
39776 Z_scripterrlog("String passed to UpperToLower() is too small. Size is: %d \n", strA.size());
39777 set_register(sarg1, 0); return;
39778 }
39779 for ( size_t q = 0; q < strA.size(); ++q )
39780 {
39781 if ( strA[q] < 'a' )
39782 strA[q] += 32 * (strA[q] >= 'A' && strA[q] <= 'Z');
39783
39784 else
39785 strA[q] -= 32 * (strA[q] >= 'a' && strA[q] <= 'z');
39786 //strA[q] -= (32 * (strA[q] >= 'a' && strA[q] <= 'z')) * (-1*((strA[q] >= 'A' && strA[q] <= 'Z')));
39787 //int32_t n = 'c';
39788
39789 //strA[q] -= 32 * ((strA[q] >= 'a' && strA[q] <= 'z')) * (-1*((strA[q] >= 'A' && strA[q] <= 'Z')));
39790 //zprint2("n is %d\n", n);
39791 //if(( strA[q] >= 'a' || strA[q] <= 'z' ) || ( strA[q] >= 'A' || strA[q] <= 'Z' ))
39792 //{
39793 // if ( strA[q] < 'a' ) { strA[q] += 32; }
39794 // else strA[q] -= 32;
39795 // continue;
39796 //}
39797
39798 }
39799 //zprint("Converted string is: %s \n", strA.c_str());
39800 if(ArrayH::setArray(arrayptr_a, strA) == SH::_Overflow)
39801 {
39802 Z_scripterrlog("Dest string supplied to 'LowerToUpper()' not large enough\n");
39803 set_register(sarg1, 0);
39804 }
39805 else set_register(sarg1, (10000));
39806 }
39807
39808 void FFScript::do_xlen(const bool v)
39809 {
39810 //not implemented, xlen not found
39811 //zprint("Running: %s\n","strlen()");
39812 int32_t arrayptr = (SH::get_arg(sarg2, v) / 10000);
39813 string str;
39814 ArrayH::getString(arrayptr, str);
39815 //zprint("strlen string size is: %d\n", str.length());
39816 //set_register(sarg1, (xlen(str.c_str()) * 10000));
39817 }
39818
39819 void FFScript::do_xtoi(const bool v)
39820 {
39821 int32_t arrayptr = (SH::get_arg(sarg2, v) / 10000);
39822 string str;
39823 ArrayH::getString(arrayptr, str);
39824 //zprint2("xtoi array pointer is: %d\n", arrayptr);
39825 //zprint2("xtoi string is %s\n", str.c_str());
39826 double val = zc_xtoi(const_cast<char*>(str.c_str()));
39827 //zprint2("xtoi val is %f\n", val);
39828 set_register(sarg1, (int32_t)(val) * 10000);
39829 }
39830 void FFScript::do_xtoi2()
39831 {
39832 int32_t arrayptr_a = ri->d[rINDEX]/10000; //get_register(sarg1) / 10000? Index and Index2 are intentional.
39833 string strA;
39834 ArrayH::getString(arrayptr_a, strA);
39835 set_register(sarg1, (zc_xtoi(strA.c_str()) * 10000));
39836 }
39837
39838 // Calculates log2 of number.
39839 double FFScript::Log2( double n )
39840 {
39841 // log(n)/log(2) is log2.
39842 return log( (double)n ) / log( (double)2 );
39843 }
39844
39845 //xtoa, convert hex number to hex ascii
39846 void FFScript::do_xtoa()
39847 {
39848
39849 int32_t arrayptr_a = get_register(sarg1) / 10000;
39850 int32_t number = get_register(sarg2) / 10000;//ri->d[rEXP2]/10000; //why are you not in sarg2?!!
39851
39852 //for ( int32_t q = 0; q < 6; ++q )
39853 // zprint2("ri->d[%d] is %d", q, ri->d[q]);
39854
39855 // zprint2("xtoa_c arrayptr_a is: %d\n",arrayptr_a);
39856 // zprint2("xtoa_c number is: %d\n",number);
39857
39858
39859
39860
39861 bool isneg = false;
39862 if ( number < 0 )
39863 {
39864 isneg = true;
39865 number *= -1;
39866 }
39867 double num = number;
39868 // zprint2("xtoa_c(), num is: %f\n", num);
39869 int32_t digits = num ? floor(FFCore.LogToBase(num, 16) + 1) : 1;
39870 //sizeof(number)*CHAR_BIT/4;
39871 // zprint2("xtoa_c, digits is: %d\n",digits);
39872
39873
39874 int32_t pos = 0;
39875 string strA;
39876 if(number == 0) //Needs to precede str.resize(digits+3) as if the number is <= 0 then this breaks.
39877 {
39878 strA.resize(3);
39879 strA[pos+2] = '0';
39880 if(ArrayH::setArray(arrayptr_a, strA) == SH::_Overflow)
39881 {
39882 Z_scripterrlog("Dest string supplied to 'itoa()' not large enough\n");
39883 set_register(sarg1, 0);
39884 }
39885 else set_register(sarg1, 30000); //returns the pointer to the dest
39886 return;
39887 }
39888 int32_t ret = 0;
39889 strA.resize(digits+3+(isneg?1:0));
39890 //num = Floor(Abs(num));
39891 if ( isneg )
39892 {
39893 strA[pos] = '-';
39894 strA[pos+1] = '0';
39895 strA[pos+2] = 'x';
39896 ret = 3;
39897 }
39898 else
39899 {
39900 strA[pos] = '0';
39901 strA[pos+1] = 'x';
39902 ret = 2;
39903 }
39904
39905 int32_t alphaoffset = 'A' - 0xA;
39906 for(int32_t i = 0; i < digits; ++i)
39907 {
39908 int32_t coeff = ((int32_t)floor((double)(((double)number) / pow((float)0x10, digits - i - 1))) % 0x10);
39909 strA[pos + ret + i] = coeff < 0xA ? coeff + '0' : coeff + alphaoffset;
39910 }
39911 if(ArrayH::setArray(arrayptr_a, strA) == SH::_Overflow)
39912 {
39913 Z_scripterrlog("Dest string supplied to 'xtoa()' not large enough\n");
39914 set_register(sarg1, 0);
39915 }
39916 //set_register(sarg1, (strcat((char)strA.c_str(), strB.c_str()) * 10000));
39917 else set_register(sarg1, (ret + digits -(isneg?1:0))*10000); //don't count the - sign as a digit
39918 }
39919
39920 void FFScript::do_ilen(const bool v)
39921 {
39922 int32_t arrayptr = (SH::get_arg(sarg2, v) / 10000);
39923 string str;
39924 ArrayH::getString(arrayptr, str);
39925 //zprint("strlen string size is: %d\n", str.length());
39926 set_register(sarg1, (FFCore.ilen((char*)str.c_str()) * 10000));
39927 }
39928
39929 //! Note atoi2 (atoi(str, len) can be accompished with str.resize after getString.
39930 void FFScript::do_atoi(const bool v)
39931 {
39932 int32_t arrayptr = (SH::get_arg(sarg2, v) / 10000);
39933 string str;
39934 ArrayH::getString(arrayptr, str);
39935 set_register(sarg1, (atoi(str.c_str()) * 10000));
39936 }
39937
39938 void FFScript::do_strstr()
39939 {
39940
39941 int32_t arrayptr_a = ri->d[rINDEX]/10000; //get_register(sarg1) / 10000? Index and Index2 are intentional.
39942 int32_t arrayptr_b = ri->d[rINDEX2]/10000; //get_register(sarg2) / 10000?
39943 string strA;
39944 string strB;
39945 ArrayH::getString(arrayptr_a, strA);
39946 ArrayH::getString(arrayptr_b, strB);
39947 if ( strA.size() < 1 )
39948 {
39949 Z_scripterrlog("String passed to strstr() is too small. Size is: %d \n", strA.size());
39950 set_register(sarg1,-10000);
39951 return;
39952 }
39953 set_register(sarg1, (strA.find(strB) * 10000));
39954 }
39955
39956 void FFScript::do_strcat()
39957 {
39958
39959 int32_t arrayptr_a = ri->d[rINDEX]/10000; //get_register(sarg1) / 10000? Index and Index2 are intentional.
39960 int32_t arrayptr_b = ri->d[rINDEX2]/10000; //get_register(sarg2) / 10000?
39961 string strA;
39962 string strB;
39963 ArrayH::getString(arrayptr_a, strA);
39964 ArrayH::getString(arrayptr_b, strB);
39965 //char str_c[2048];
39966 //strcpy(str_c, strA.c_str());
39967 string strC = strA + strB;
39968 //zprint("strcat string: %s\n", strC.c_str());
39969 if(ArrayH::setArray(arrayptr_a, strC) == SH::_Overflow)
39970 {
39971 Z_scripterrlog("Dest string supplied to 'strcat()' not large enough\n");
39972 set_register(sarg1, 0);
39973 }
39974 //set_register(sarg1, (strcat((char)strA.c_str(), strB.c_str()) * 10000));
39975 else set_register(sarg1, arrayptr_a); //returns the pointer to the dest
39976 }
39977 void FFScript::do_strspn()
39978 {
39979
39980 int32_t arrayptr_a = ri->d[rINDEX]/10000; //get_register(sarg1) / 10000? Index and Index2 are intentional.
39981 int32_t arrayptr_b = ri->d[rINDEX2]/10000; //get_register(sarg2) / 10000?
39982 string strA;
39983 string strB;
39984 ArrayH::getString(arrayptr_a, strA);
39985 ArrayH::getString(arrayptr_b, strB);
39986 set_register(sarg1, (strspn(strA.c_str(), strB.c_str()) * 10000));
39987 }
39988
39989 void FFScript::do_strcspn()
39990 {
39991
39992 int32_t arrayptr_a = ri->d[rINDEX]/10000; //get_register(sarg1) / 10000? Index and Index2 are intentional.
39993 int32_t arrayptr_b = ri->d[rINDEX2]/10000;
39994 string strA;
39995 string strB;
39996 ArrayH::getString(arrayptr_a, strA);
39997 ArrayH::getString(arrayptr_b, strB);
39998 set_register(sarg1, (strcspn(strA.c_str(), strB.c_str()) * 10000));
39999 }
40000
40001 void FFScript::do_strchr()
40002 {
40003
40004 int32_t arrayptr_a = ri->d[rINDEX]/10000; //get_register(sarg1) / 10000? Index and Index2 are intentional.
40005 char chr_to_find = (ri->d[rINDEX2]/10000);
40006 string strA;
40007 ArrayH::getString(arrayptr_a, strA);
40008 if ( strA.size() < 1 )
40009 {
40010 Z_scripterrlog("String passed to strchr() is too small. Size is: %d \n", strA.size());
40011 set_register(sarg1,-10000);
40012 return;
40013 }
40014
40015 set_register(sarg1,strA.find_first_of(chr_to_find)*10000);
40016 }
40017 void FFScript::do_strrchr()
40018 {
40019 int32_t arrayptr_a = ri->d[rINDEX]/10000; //get_register(sarg1) / 10000? Index and Index2 are intentional.
40020 char chr_to_find = (ri->d[rINDEX2]/10000);
40021 string strA;
40022 ArrayH::getString(arrayptr_a, strA);
40023 if ( strA.size() < 1 )
40024 {
40025 Z_scripterrlog("String passed to strrchr() is too small. Size is: %d \n", strA.size());
40026 set_register(sarg1,-10000);
40027 return;
40028 }
40029 set_register(sarg1,strA.find_last_of(chr_to_find)*10000);
40030 }
40031
40032 void FFScript::do_remchr2()
40033 {
40034 //Not implemented, remchr not found
40035 //not part of any standard library
40036 int32_t arrayptr_a = ri->d[rINDEX]/10000; //get_register(sarg1) / 10000? Index and Index2 are intentional.
40037 string strA;
40038 ArrayH::getString(arrayptr_a, strA);
40039 //set_register(sarg1, (remchr(strA.c_str(), (ri->d[rINDEX2]/10000)) * 10000));
40040 }
40041 //Bookmark
40042 void FFScript::do_atoi2()
40043 {
40044 //not implemented; atoi does not take 2 params
40045 int32_t arrayptr_a = ri->d[rINDEX]/10000;
40046 string strA;
40047 ArrayH::getString(arrayptr_a, strA);
40048 //set_register(sarg1, (atoi(strA.c_str(), (ri->d[rINDEX2]/10000)) * 10000));
40049 }
40050 void FFScript::do_ilen2()
40051 {
40052 //not implemented, ilen not found
40053 int32_t arrayptr_a = ri->d[rINDEX]/10000;
40054 string strA;
40055 ArrayH::getString(arrayptr_a, strA);
40056 //set_register(sarg1, (ilen(strA.c_str(), (ri->d[rINDEX2]/10000)) * 10000));
40057 }
40058 void FFScript::do_xlen2()
40059 {
40060 //not implemented, xlen not found
40061 int32_t arrayptr_a = ri->d[rINDEX]/10000;
40062 string strA;
40063 ArrayH::getString(arrayptr_a, strA);
40064 //set_register(sarg1, (xlen(strA.c_str(), (ri->d[rINDEX2]/10000)) * 10000));
40065 }
40066
40067 978 void FFScript::do_itoa()
40068 {
40069 978 int32_t arrayptr_a = get_register(sarg1) / 10000;
40070 978 int32_t number = get_register(sarg2) / 10000;
40071
40072 char buf[16];
40073 978 zc_itoa(number, buf, 10);
40074 978 int32_t ret = ::strlen(buf) * 10000L;
40075
1/2
✓ Branch 0 taken 978 times.
✗ Branch 1 not taken.
978 string strA(buf);
40076
40077
2/4
✓ Branch 0 taken 978 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 978 times.
978 if(ArrayH::setArray(arrayptr_a, strA) == SH::_Overflow)
40078 {
40079 Z_scripterrlog("Dest string supplied to 'itoa()' not large enough\n");
40080 set_register(sarg1, -1);
40081 }
40082
1/2
✓ Branch 0 taken 978 times.
✗ Branch 1 not taken.
978 else set_register(sarg1, ret); //returns the number of digits used
40083 978 }
40084
40085 void FFScript::do_itoacat()
40086 {
40087
40088 int32_t arrayptr_a = get_register(sarg1) / 10000;
40089 int32_t number = get_register(sarg2) / 10000;
40090
40091 // zprint2("itoacat arrayptr_a is: %d\n",arrayptr_a);
40092 // zprint2("itoacat number is: %d\n",number);
40093
40094 double num = number;
40095 int32_t digits = FFCore.numDigits(number); //int32_t(log10(temp) * 10000.0)
40096 // zprint2("itoacat, digits is: %d\n",digits);
40097 int32_t pos = 0;
40098 int32_t ret = 0;
40099 string strA;
40100 string strB;
40101 strB.resize(digits);
40102 ArrayH::getString(arrayptr_a, strA);
40103 if(num < 0)
40104 {
40105 strB.resize(digits+1);
40106 strB[pos] = '-';
40107 ++ret;
40108 num = -num;
40109 }
40110 else if(num == 0)
40111 {
40112 strB[pos] = '0';
40113 string strC = strA + strB;
40114 if(ArrayH::setArray(arrayptr_a, strC) == SH::_Overflow)
40115 {
40116 Z_scripterrlog("Dest string supplied to 'itoacat()' not large enough\n");
40117 set_register(sarg1, 0);
40118 }
40119 else set_register(sarg1, arrayptr_a); //returns the pointer to the dest
40120 return;
40121 }
40122
40123
40124 for(int32_t i = 0; i < digits; ++i)
40125 strB[pos + ret + i] = ((int32_t)floor((double)(num / pow((float)10, digits - i - 1))) % 10) + '0';
40126
40127 string strC = strA + strB;
40128 if(ArrayH::setArray(arrayptr_a, strC) == SH::_Overflow)
40129 {
40130 Z_scripterrlog("Dest string supplied to 'itoacat()' not large enough\n");
40131 set_register(sarg1, 0);
40132 }
40133 //set_register(sarg1, (strcat((char)strB.c_str(), strB.c_str()) * 10000));
40134 else set_register(sarg1, arrayptr_a); //returns the pointer to the dest
40135 }
40136
40137 /*
40138 void FFScript::do_itoa()
40139 {
40140
40141 int32_t arrayptr_a = ri->d[rINDEX2]/10000;
40142 int32_t value = ri->d[rINDEX]/10000;
40143 char the_string[13];
40144 char* chrptr = NULL;
40145 chrptr = zc_itoa(value, the_string, 10);
40146 //Returns the number of characters used.
40147 if(ArrayH::setArray(arrayptr_a, the_string) == SH::_Overflow)
40148 Z_scripterrlog("Dest string supplied to 'itoa()' not large enough\n");
40149 set_register(sarg1, (FFCore.zc_strlen(the_string)*10000));
40150 }
40151 */
40152
40153 93 void FFScript::do_strcpy(const bool a, const bool b)
40154 {
40155 93 int32_t arrayptr_b = SH::get_arg(sarg1, a) / 10000;
40156 93 int32_t arrayptr_a = SH::get_arg(sarg2, b) / 10000;
40157
40158 93 string strA;
40159
40160
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 ArrayH::getString(arrayptr_a, strA);
40161
40162
2/4
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 93 times.
93 if(ArrayH::setArray(arrayptr_b, strA) == SH::_Overflow)
40163 Z_scripterrlog("Dest string supplied to 'strcpy()' not large enough\n");
40164 93 }
40165 void FFScript::do_arraycpy(const bool a, const bool b)
40166 {
40167 int32_t arrayptr_dest = SH::get_arg(sarg1, a) / 10000;
40168 int32_t arrayptr_src = SH::get_arg(sarg2, b) / 10000;
40169 ArrayH::copyValues(arrayptr_dest, arrayptr_src, ArrayH::getSize(arrayptr_src));
40170 }
40171 void FFScript::do_strlen(const bool v)
40172 {
40173 //zprint("Running: %s\n","strlen()");
40174 int32_t arrayptr = (SH::get_arg(sarg2, v) / 10000);
40175 string str;
40176 ArrayH::getString(arrayptr, str);
40177 //zprint("strlen string size is: %d\n", str.length());
40178 set_register(sarg1, (str.length() * 10000));
40179 }
40180
40181 void FFScript::do_strncmp()
40182 {
40183 int32_t arrayptr_a = ri->d[rINDEX]/10000;
40184 int32_t arrayptr_b = ri->d[rEXP2]/10000;
40185 int32_t len = ri->d[rEXP1]/10000;
40186 string strA;
40187 string strB;
40188 ArrayH::getString(arrayptr_a, strA);
40189 ArrayH::getString(arrayptr_b, strB);
40190 set_register(sarg1, (strncmp(strA.c_str(), strB.c_str(), len) * 10000));
40191 }
40192
40193 void FFScript::do_strnicmp()
40194 {
40195 int32_t arrayptr_a = ri->d[rINDEX]/10000;
40196 int32_t arrayptr_b = ri->d[rEXP2]/10000;
40197 int32_t len = ri->d[rEXP1]/10000;
40198 string strA;
40199 string strB;
40200 ArrayH::getString(arrayptr_a, strA);
40201 ArrayH::getString(arrayptr_b, strB);
40202 set_register(sarg1, (ustrnicmp(strA.c_str(), strB.c_str(), len) * 10000));
40203 }
40204
40205 void FFScript::do_npc_canmove(const bool v)
40206 {
40207 int32_t arrayptr = SH::get_arg(sarg1, v) / 10000;
40208 int32_t sz = ArrayH::getSize(arrayptr);
40209 //bool can_mv = false;
40210 if(GuyH::loadNPC(ri->guyref, "npc->CanMove()") == SH::_NoError)
40211 {
40212 ArrayManager am(arrayptr);
40213 if(am.invalid()) return;
40214 if ( sz == 1 ) //bool canmove(int32_t ndir): dir only, uses 'step' IIRC
40215 {
40216 set_register(sarg1, ( GuyH::getNPC()->canmove((am.get(0)/10000),false)) ? 10000 : 0);
40217 }
40218 else if ( sz == 2 ) //bool canmove(int32_t ndir, int32_t special): I think that this also uses the default 'step'
40219 {
40220 set_register(sarg1, ( GuyH::getNPC()->canmove((am.get(0)/10000),(zfix)(am.get(1)/10000), false)) ? 10000 : 0);
40221 }
40222 else if ( sz == 3 ) //bool canmove(int32_t ndir,zfix s,int32_t special) : I'm pretty sure that 'zfix s' is 'step' here.
40223 {
40224 set_register(sarg1, ( GuyH::getNPC()->canmove((am.get(0)/10000),(zfix)(am.get(1)/10000),(am.get(2)/10000),false)) ? 10000 : 0);
40225 }
40226 else if ( sz == 7 ) //bool canmove(int32_t ndir,zfix s,int32_t special) : I'm pretty sure that 'zfix s' is 'step' here.
40227 {
40228 set_register(sarg1, ( GuyH::getNPC()->canmove((am.get(0)/10000),(zfix)(am.get(1)/10000),(am.get(2)/10000),(am.get(3)/10000),(am.get(4)/10000),(am.get(5)/10000),(am.get(6)/10000),false)) ? 10000 : 0);
40229 }
40230 else
40231 {
40232 Z_scripterrlog("Invalid array size (%d) passed to npc->CanMove(). The array size must be [1], [2], [3], or [7].\n", sz);
40233 //can_mv = false;
40234 set_register(sarg1, 0);
40235 }
40236 }
40237 //set_register(sarg1, ( can_mv ? 10000 : 0));
40238 }
40239
40240 //void do_get_enh_music_filename(const bool v)
40241 void FFScript::get_npcdata_initd_label(const bool v)
40242 {
40243 int32_t init_d_index = SH::get_arg(sarg1, v) / 10000;
40244 int32_t arrayptr = get_register(sarg2) / 10000;
40245
40246 if((unsigned)init_d_index > 7)
40247 {
40248 Z_scripterrlog("Invalid InitD[] index (%d) passed to npcdata->GetInitDLabel().\n", init_d_index);
40249 return;
40250 }
40251
40252 if(ArrayH::setArray(arrayptr, string(guysbuf[ri->npcdataref].initD_label[init_d_index])) == SH::_Overflow)
40253 Z_scripterrlog("Array supplied to 'npcdata->GetInitDLabel()' not large enough\n");
40254 }
40255
40256 /////////////////////
40257 /// MATHS HELPERS ///
40258 /////////////////////
40259
40260 //Returns the log of val to the base 10. Any value <= 0 will return 0.
40261 int32_t FFScript::Log10(double temp)
40262 {
40263 int32_t ret = 0;
40264 if(temp > 0)
40265 ret = int32_t(log10(temp) * 10000.0);
40266 else ret = 0;
40267 return ret;
40268 }
40269
40270 //Returns the number of digits in a given integer.
40271 int32_t FFScript::numDigits(int32_t number)
40272 {
40273 int32_t digits = 0;
40274 while (number)
40275 {
40276 number /= 10;
40277 digits++;
40278 }
40279 return digits;
40280 }
40281
40282 // Returns the natural logarithm of val (to the base e). Any value <= 0 will return 0.
40283 double FFScript::ln(double temp)
40284 {
40285
40286 if(temp > 0)
40287 return (log(temp));
40288 else
40289 {
40290 return 0;
40291 }
40292 }
40293
40294 // Returns the logarithm of x to the given base.
40295 double FFScript::LogToBase(double x, double base)
40296 {
40297 if(x <= 0 || base <= 0) return 0;
40298 return FFCore.ln(x)/FFCore.ln(base);
40299 }
40300
40301 script_command ZASMcommands[NUMCOMMANDS+1]=
40302 {
40303 //name args arg1 arg2 more
40304 { "SETV", 2, 0, 1, 0},
40305 { "SETR", 2, 0, 0, 0},
40306 { "ADDR", 2, 0, 0, 0},
40307 { "ADDV", 2, 0, 1, 0},
40308 { "SUBR", 2, 0, 0, 0},
40309 { "SUBV", 2, 0, 1, 0},
40310 { "MULTR", 2, 0, 0, 0},
40311 { "MULTV", 2, 0, 1, 0},
40312 { "DIVR", 2, 0, 0, 0},
40313 { "DIVV", 2, 0, 1, 0},
40314 { "WAITFRAME", 0, 0, 0, 0},
40315 { "GOTO", 1, 1, 0, 0},
40316 { "CHECKTRIG", 0, 0, 0, 0},
40317 { "WARP", 2, 1, 1, 0},
40318 { "COMPARER", 2, 0, 0, 0},
40319 { "COMPAREV", 2, 0, 1, 0},
40320 { "GOTOTRUE", 1, 1, 0, 0},
40321 { "GOTOFALSE", 1, 1, 0, 0},
40322 { "GOTOLESS", 1, 1, 0, 0},
40323 { "GOTOMORE", 1, 1, 0, 0},
40324 { "LOAD1", 2, 0, 0, 0},
40325 { "LOAD2", 2, 0, 0, 0},
40326 { "SETA1", 2, 0, 0, 0},
40327 { "SETA2", 2, 0, 0, 0},
40328 { "QUIT", 0, 0, 0, 0},
40329 { "SINR", 2, 0, 0, 0},
40330 { "SINV", 2, 0, 1, 0},
40331 { "COSR", 2, 0, 0, 0},
40332 { "COSV", 2, 0, 1, 0},
40333 { "TANR", 2, 0, 0, 0},
40334 { "TANV", 2, 0, 1, 0},
40335 { "MODR", 2, 0, 0, 0},
40336 { "MODV", 2, 0, 1, 0},
40337 { "ABS", 1, 0, 0, 0},
40338 { "MINR", 2, 0, 0, 0},
40339 { "MINV", 2, 0, 1, 0},
40340 { "MAXR", 2, 0, 0, 0},
40341 { "MAXV", 2, 0, 1, 0},
40342 { "RNDR", 2, 0, 0, 0},
40343 { "RNDV", 2, 0, 1, 0},
40344 { "FACTORIAL", 1, 0, 0, 0},
40345 { "POWERR", 2, 0, 0, 0},
40346 { "POWERV", 2, 0, 1, 0},
40347 { "IPOWERR", 2, 0, 0, 0},
40348 { "IPOWERV", 2, 0, 1, 0},
40349 { "ANDR", 2, 0, 0, 0},
40350 { "ANDV", 2, 0, 1, 0},
40351 { "ORR", 2, 0, 0, 0},
40352 { "ORV", 2, 0, 1, 0},
40353 { "XORR", 2, 0, 0, 0},
40354 { "XORV", 2, 0, 1, 0},
40355 { "NANDR", 2, 0, 0, 0},
40356 { "NANDV", 2, 0, 1, 0},
40357 { "NORR", 2, 0, 0, 0},
40358 { "NORV", 2, 0, 1, 0},
40359 { "XNORR", 2, 0, 0, 0},
40360 { "XNORV", 2, 0, 1, 0},
40361 { "NOT", 1, 0, 0, 0},
40362 { "LSHIFTR", 2, 0, 0, 0},
40363 { "LSHIFTV", 2, 0, 1, 0},
40364 { "RSHIFTR", 2, 0, 0, 0},
40365 { "RSHIFTV", 2, 0, 1, 0},
40366 { "TRACER", 1, 0, 0, 0},
40367 { "TRACEV", 1, 1, 0, 0},
40368 { "TRACE3", 0, 0, 0, 0},
40369 { "LOOP", 2, 1, 0, 0},
40370 { "PUSHR", 1, 0, 0, 0},
40371 { "PUSHV", 1, 1, 0, 0},
40372 { "POP", 1, 0, 0, 0},
40373 { "ENQUEUER", 2, 0, 0, 0},
40374 { "ENQUEUEV", 2, 0, 1, 0},
40375 { "DEQUEUE", 1, 0, 0, 0},
40376 { "PLAYSOUNDR", 1, 0, 0, 0},
40377 { "PLAYSOUNDV", 1, 1, 0, 0},
40378 { "LOADLWEAPONR", 1, 0, 0, 0},
40379 { "LOADLWEAPONV", 1, 1, 0, 0},
40380 { "LOADITEMR", 1, 0, 0, 0},
40381 { "LOADITEMV", 1, 1, 0, 0},
40382 { "LOADNPCR", 1, 0, 0, 0},
40383 { "LOADNPCV", 1, 1, 0, 0},
40384 { "CREATELWEAPONR", 1, 0, 0, 0},
40385 { "CREATELWEAPONV", 1, 1, 0, 0},
40386 { "CREATEITEMR", 1, 0, 0, 0},
40387 { "CREATEITEMV", 1, 1, 0, 0},
40388 { "CREATENPCR", 1, 0, 0, 0},
40389 { "CREATENPCV", 1, 1, 0, 0},
40390 { "LOADI", 2, 0, 0, 0},
40391 { "STOREI", 2, 0, 0, 0},
40392 { "GOTOR", 1, 0, 0, 0},
40393 { "SQROOTV", 2, 0, 1, 0},
40394 { "SQROOTR", 2, 0, 0, 0},
40395 { "CREATEEWEAPONR", 1, 0, 0, 0},
40396 { "CREATEEWEAPONV", 1, 1, 0, 0},
40397 { "PITWARP", 2, 1, 1, 0},
40398 { "WARPR", 2, 0, 0, 0},
40399 { "PITWARPR", 2, 0, 0, 0},
40400 { "CLEARSPRITESR", 1, 0, 0, 0},
40401 { "CLEARSPRITESV", 1, 1, 0, 0},
40402 { "RECT", 0, 0, 0, 0},
40403 { "CIRCLE", 0, 0, 0, 0},
40404 { "ARC", 0, 0, 0, 0},
40405 { "ELLIPSE", 0, 0, 0, 0},
40406 { "LINE", 0, 0, 0, 0},
40407 { "PUTPIXEL", 0, 0, 0, 0},
40408 { "DRAWTILE", 0, 0, 0, 0},
40409 { "DRAWCOMBO", 0, 0, 0, 0},
40410 { "ELLIPSE2", 0, 0, 0, 0},
40411 { "SPLINE", 0, 0, 0, 0},
40412 { "FLOODFILL", 0, 0, 0, 0},
40413 { "COMPOUNDR", 1, 0, 0, 0},
40414 { "COMPOUNDV", 1, 1, 0, 0},
40415 { "MSGSTRR", 1, 0, 0, 0},
40416 { "MSGSTRV", 1, 1, 0, 0},
40417 { "ISVALIDITEM", 1, 0, 0, 0},
40418 { "ISVALIDNPC", 1, 0, 0, 0},
40419 { "PLAYMIDIR", 1, 0, 0, 0},
40420 { "PLAYMIDIV", 1, 1, 0, 0},
40421 { "COPYTILEVV", 2, 1, 1, 0},
40422 { "COPYTILEVR", 2, 1, 0, 0},
40423 { "COPYTILERV", 2, 0, 1, 0},
40424 { "COPYTILERR", 2, 0, 0, 0},
40425 { "SWAPTILEVV", 2, 1, 1, 0},
40426 { "SWAPTILEVR", 2, 1, 0, 0},
40427 { "SWAPTILERV", 2, 0, 1, 0},
40428 { "SWAPTILERR", 2, 0, 0, 0},
40429 { "CLEARTILEV", 1, 1, 0, 0},
40430 { "CLEARTILER", 1, 0, 0, 0},
40431 { "OVERLAYTILEVV", 2, 1, 1, 0},
40432 { "OVERLAYTILEVR", 2, 1, 0, 0},
40433 { "OVERLAYTILERV", 2, 0, 1, 0},
40434 { "OVERLAYTILERR", 2, 0, 0, 0},
40435 { "FLIPROTTILEVV", 2, 1, 1, 0},
40436 { "FLIPROTTILEVR", 2, 1, 0, 0},
40437 { "FLIPROTTILERV", 2, 0, 1, 0},
40438 { "FLIPROTTILERR", 2, 0, 0, 0},
40439 { "GETTILEPIXELV", 1, 1, 0, 0},
40440 { "GETTILEPIXELR", 1, 0, 0, 0},
40441 { "SETTILEPIXELV", 1, 1, 0, 0},
40442 { "SETTILEPIXELR", 1, 0, 0, 0},
40443 { "SHIFTTILEVV", 2, 1, 1, 0},
40444 { "SHIFTTILEVR", 2, 1, 0, 0},
40445 { "SHIFTTILERV", 2, 0, 1, 0},
40446 { "SHIFTTILERR", 2, 0, 0, 0},
40447 { "ISVALIDLWPN", 1, 0, 0, 0},
40448 { "ISVALIDEWPN", 1, 0, 0, 0},
40449 { "LOADEWEAPONR", 1, 0, 0, 0},
40450 { "LOADEWEAPONV", 1, 1, 0, 0},
40451 { "ALLOCATEMEMR", 2, 0, 0, 0},
40452 { "ALLOCATEMEMV", 2, 0, 1, 0},
40453 { "ALLOCATEGMEMV", 2, 0, 1, 0},
40454 { "DEALLOCATEMEMR", 1, 0, 0, 0},
40455 { "DEALLOCATEMEMV", 1, 1, 0, 0},
40456 { "WAITDRAW", 0, 0, 0, 0},
40457 { "ARCTANR", 1, 0, 0, 0},
40458 { "LWPNUSESPRITER", 1, 0, 0, 0},
40459 { "LWPNUSESPRITEV", 1, 1, 0, 0},
40460 { "EWPNUSESPRITER", 1, 0, 0, 0},
40461 { "EWPNUSESPRITEV", 1, 1, 0, 0},
40462 { "LOADITEMDATAR", 1, 0, 0, 0},
40463 { "LOADITEMDATAV", 1, 1, 0, 0},
40464 { "BITNOT", 1, 0, 0, 0},
40465 { "LOG10", 1, 0, 0, 0},
40466 { "LOGE", 1, 0, 0, 0},
40467 { "ISSOLID", 1, 0, 0, 0},
40468 { "LAYERSCREEN", 2, 0, 0, 0},
40469 { "LAYERMAP", 2, 0, 0, 0},
40470 { "TRACE2R", 1, 0, 0, 0},
40471 { "TRACE2V", 1, 1, 0, 0},
40472 { "TRACE4", 0, 0, 0, 0},
40473 { "TRACE5", 0, 0, 0, 0},
40474 { "SECRETS", 0, 0, 0, 0},
40475 { "DRAWCHAR", 0, 0, 0, 0},
40476 { "GETSCREENFLAGS", 1, 0, 0, 0},
40477 { "QUAD", 0, 0, 0, 0},
40478 { "TRIANGLE", 0, 0, 0, 0},
40479 { "ARCSINR", 2, 0, 0, 0},
40480 { "ARCSINV", 2, 1, 0, 0},
40481 { "ARCCOSR", 2, 0, 0, 0},
40482 { "ARCCOSV", 2, 1, 0, 0},
40483 { "GAMEEND", 0, 0, 0, 0},
40484 { "DRAWINT", 0, 0, 0, 0},
40485 { "SETTRUE", 1, 0, 0, 0},
40486 { "SETFALSE", 1, 0, 0, 0},
40487 { "SETMORE", 1, 0, 0, 0},
40488 { "SETLESS", 1, 0, 0, 0},
40489 { "FASTTILE", 0, 0, 0, 0},
40490 { "FASTCOMBO", 0, 0, 0, 0},
40491 { "DRAWSTRING", 0, 0, 0, 0},
40492 { "SETSIDEWARP", 0, 0, 0, 0},
40493 { "SAVE", 0, 0, 0, 0},
40494 { "TRACE6", 0, 0, 0, 0},
40495 { "DEPRECATED", 1, 0, 0, 0},
40496 { "QUAD3D", 0, 0, 0, 0},
40497 { "TRIANGLE3D", 0, 0, 0, 0},
40498 { "SETCOLORB", 0, 0, 0, 0},
40499 { "SETDEPTHB", 0, 0, 0, 0},
40500 { "GETCOLORB", 0, 0, 0, 0},
40501 { "GETDEPTHB", 0, 0, 0, 0},
40502 { "COMBOTILE", 2, 0, 0, 0},
40503 { "SETTILEWARP", 0, 0, 0, 0},
40504 { "GETSCREENEFLAGS", 1, 0, 0, 0},
40505 { "GETSAVENAME", 1, 0, 0, 0},
40506 { "ARRAYSIZE", 1, 0, 0, 0},
40507 { "ITEMNAME", 1, 0, 0, 0},
40508 { "SETSAVENAME", 1, 0, 0, 0},
40509 { "NPCNAME", 1, 0, 0, 0},
40510 { "GETMESSAGE", 2, 0, 0, 0},
40511 { "GETDMAPNAME", 2, 0, 0, 0},
40512 { "GETDMAPTITLE", 2, 0, 0, 0},
40513 { "GETDMAPINTRO", 2, 0, 0, 0},
40514 { "ALLOCATEGMEMR", 2, 0, 0, 0},
40515 { "DRAWBITMAP", 0, 0, 0, 0},
40516 { "SETRENDERTARGET", 0, 0, 0, 0},
40517 { "PLAYENHMUSIC", 2, 0, 0, 0},
40518 { "GETMUSICFILE", 2, 0, 0, 0},
40519 { "GETMUSICTRACK", 1, 0, 0, 0},
40520 { "SETDMAPENHMUSIC", 0, 0, 0, 0},
40521 { "DRAWLAYER", 0, 0, 0, 0},
40522 { "DRAWSCREEN", 0, 0, 0, 0},
40523 { "BREAKSHIELD", 1, 0, 0, 0},
40524 { "SAVESCREEN", 1, 0, 0, 0},
40525 { "SAVEQUITSCREEN", 0, 0, 0, 0},
40526 { "SELECTAWPNR", 1, 0, 0, 0},
40527 { "SELECTAWPNV", 1, 1, 0, 0},
40528 { "SELECTBWPNR", 1, 0, 0, 0},
40529 { "SELECTBWPNV", 1, 1, 0, 0},
40530 { "GETSIDEWARPDMAP", 1, 0, 0, 0},
40531 { "GETSIDEWARPSCR", 1, 0, 0, 0},
40532 { "GETSIDEWARPTYPE", 1, 0, 0, 0},
40533 { "GETTILEWARPDMAP", 1, 0, 0, 0},
40534 { "GETTILEWARPSCR", 1, 0, 0, 0},
40535 { "GETTILEWARPTYPE", 1, 0, 0, 0},
40536 { "GETFFCSCRIPT", 1, 0, 0, 0},
40537 { "BITMAPEXR", 0, 0, 0, 0},
40538 { "__RESERVED_FOR_QUAD2R", 0, 0, 0, 0},
40539 { "WAVYIN", 0, 0, 0, 0},
40540 { "WAVYOUT", 0, 0, 0, 0},
40541 { "ZAPIN", 0, 0, 0, 0},
40542 { "ZAPOUT", 0, 0, 0, 0},
40543 { "OPENWIPE", 0, 0, 0, 0},
40544 { "FREE0x00F1", 0, 0, 0, 0 },
40545 { "FREE0x00F2", 0, 0, 0, 0},
40546 { "FREE0x00F3", 0, 0, 0,0},
40547 { "SETMESSAGE", 2, 0, 0, 0},
40548 { "SETDMAPNAME", 2, 0, 0, 0},
40549 { "SETDMAPTITLE", 2, 0, 0, 0},
40550 { "SETDMAPINTRO", 2, 0, 0, 0},
40551 { "GREYSCALEON", 0, 0, 0, 0},
40552 { "GREYSCALEOFF", 0, 0, 0, 0},
40553 { "ENDSOUNDR", 1, 0, 0, 0},
40554 { "ENDSOUNDV", 1, 1, 0, 0},
40555 { "PAUSESOUNDR", 1, 0, 0, 0},
40556 { "PAUSESOUNDV", 1, 1, 0, 0},
40557 { "RESUMESOUNDR", 1, 0, 0, 0},
40558 { "RESUMESOUNDV", 1, 1, 0, 0},
40559 { "PAUSEMUSIC", 0, 0, 0, 0},
40560 { "RESUMEMUSIC", 0, 0, 0, 0},
40561 { "LWPNARRPTR", 1, 0, 0, 0},
40562 { "EWPNARRPTR", 1, 0, 0, 0},
40563 { "EWPNARRPTR", 1, 0, 0, 0},
40564 { "IDATAARRPTR", 1, 0, 0, 0},
40565 { "FFCARRPTR", 1, 0, 0, 0},
40566 { "BOOLARRPTR", 1, 0, 0, 0},
40567 { "BOOLARRPTR", 1, 0, 0, 0},
40568 { "LWPNARRPTR2", 1, 0, 0, 0},
40569 { "EWPNARRPTR2", 1, 0, 0, 0},
40570 { "ITEMARRPTR2", 1, 0, 0, 0},
40571 { "IDATAARRPTR2", 1, 0, 0, 0},
40572 { "FFCARRPTR2", 1, 0, 0, 0},
40573 { "BOOLARRPTR2", 1, 0, 0, 0},
40574 { "NPCARRPTR2", 1, 0, 0, 0},
40575 { "ARRAYSIZEB", 1, 0, 0, 0},
40576 { "ARRAYSIZEF", 1, 0, 0, 0},
40577 { "ARRAYSIZEN", 1, 0, 0, 0},
40578 { "ARRAYSIZEL", 1, 0, 0, 0},
40579 { "ARRAYSIZEE", 1, 0, 0, 0},
40580 { "ARRAYSIZEI", 1, 0, 0, 0},
40581 { "ARRAYSIZEID", 1, 0, 0, 0},
40582 { "POLYGONR", 0, 0, 0, 0},
40583 { "__RESERVED_FOR_POLYGON3DR", 0, 0, 0, 0},
40584 { "__RESERVED_FOR_SETRENDERSOURCE", 0, 0, 0, 0},
40585 { "LINESARRAY", 0, 0, 0, 0},
40586 { "PIXELARRAYR", 0, 0, 0, 0},
40587 { "TILEARRAYR", 0, 0, 0, 0},
40588 { "COMBOARRAYR", 0, 0, 0, 0},
40589 { "RES0000", 0, 0, 0, 0},
40590 { "RES0001", 0, 0, 0, 0},
40591 { "RES0002", 0, 0, 0, 0},
40592 { "RES0003", 0, 0, 0, 0},
40593 { "RES0004", 0, 0, 0, 0},
40594 { "RES0005", 0, 0, 0, 0},
40595 { "RES0006", 0, 0, 0, 0},
40596 { "RES0007", 0, 0, 0, 0},
40597 { "RES0008", 0, 0, 0, 0},
40598 { "RES0009", 0, 0, 0, 0},
40599 { "RES000A", 0, 0, 0, 0},
40600 { "RES000B", 0, 0, 0, 0},
40601 { "RES000C", 0, 0, 0, 0},
40602 { "RES000D", 0, 0, 0, 0},
40603 { "RES000E", 0, 0, 0, 0},
40604 { "RES000F", 0, 0, 0, 0},
40605 { "__RESERVED_FOR_CREATELWPN2VV", 2, 1, 1, 0},
40606 { "__RESERVED_FOR_CREATELWPN2VR", 2, 1, 0, 0},
40607 { "__RESERVED_FOR_CREATELWPN2RV", 2, 0, 1, 0},
40608 { "__RESERVED_FOR_CREATELWPN2RR", 2, 0, 0, 0},
40609 { "GETSCREENDOOR", 1, 0, 0, 0},
40610 { "GETSCREENENEMY", 1, 0, 0, 0},
40611 { "PAUSESFX", 1, 0, 0, 0},
40612 { "RESUMESFX", 1, 0, 0, 0},
40613 { "CONTINUESFX", 1, 0, 0, 0},
40614 { "ADJUSTSFX", 0, 0, 0, 0},
40615 { "GETITEMSCRIPT", 1, 0, 0, 0},
40616 { "GETSCREENLAYOP", 1, 0, 0, 0},
40617 { "GETSCREENSECCMB", 1, 0, 0, 0},
40618 { "GETSCREENSECCST", 1, 0, 0, 0},
40619 { "GETSCREENSECFLG", 1, 0, 0, 0},
40620 { "GETSCREENLAYMAP", 1, 0, 0, 0},
40621 { "GETSCREENLAYSCR", 1, 0, 0, 0},
40622 { "GETSCREENPATH", 1, 0, 0, 0},
40623 { "GETSCREENWARPRX", 1, 0, 0, 0},
40624 { "GETSCREENWARPRY", 1, 0, 0, 0},
40625 { "TRIGGERSECRETR", 1, 0, 0, 0},
40626 { "TRIGGERSECRETV", 1, 1, 0, 0},
40627 { "NIL_UNUSED_1", 1, 0, 0, 0},
40628 { "NIL_UNUSED_2", 1, 1, 0, 0},
40629 //NPCData
40630 //one input, one return
40631 { "GETNPCDATAFLAGS", 2, 0, 0, 0},
40632 { "GETNPCDATAFLAGS2", 2, 0, 0, 0},
40633 { "GETNPCDATAWIDTH", 2, 0, 0, 0},
40634 { "GETNPCDATAHEIGHT", 2, 0, 0, 0},
40635 { "GETNPCDATASTILE", 2, 0, 0, 0},
40636 { "GETNPCDATASWIDTH", 2, 0, 0, 0},
40637 { "GETNPCDATASHEIGHT", 2, 0, 0, 0},
40638 { "GETNPCDATAETILE", 2, 0, 0, 0},
40639 { "GETNPCDATAEWIDTH", 2, 0, 0, 0},
40640 { "GETNPCDATAHP", 2, 0, 0, 0},
40641 { "GETNPCDATAFAMILY", 2, 0, 0, 0},
40642 { "GETNPCDATACSET", 2, 0, 0, 0},
40643 { "GETNPCDATAANIM", 2, 0, 0, 0},
40644 { "GETNPCDATAEANIM", 2, 0, 0, 0},
40645 { "GETNPCDATAFRAMERATE", 2, 0, 0, 0},
40646 { "GETNPCDATAEFRAMERATE", 2, 0, 0, 0},
40647 { "GETNPCDATATOUCHDMG", 2, 0, 0, 0},
40648 { "GETNPCDATAWPNDAMAGE", 2, 0, 0, 0},
40649 { "GETNPCDATAWEAPON", 2, 0, 0, 0},
40650 { "GETNPCDATARANDOM", 2, 0, 0, 0},
40651 { "GETNPCDATAHALT", 2, 0, 0, 0},
40652 { "GETNPCDATASTEP", 2, 0, 0, 0},
40653 { "GETNPCDATAHOMING", 2, 0, 0, 0},
40654 { "GETNPCDATAHUNGER", 2, 0, 0, 0},
40655 { "GETNPCDATADROPSET", 2, 0, 0, 0},
40656 { "GETNPCDATABGSFX", 2, 0, 0, 0},
40657 { "GETNPCDATADEATHSFX", 2, 0, 0, 0},
40658 { "GETNPCDATAXOFS", 2, 0, 0, 0},
40659 { "GETNPCDATAYOFS", 2, 0, 0, 0},
40660 { "GETNPCDATAZOFS", 2, 0, 0, 0},
40661 { "GETNPCDATAHXOFS", 2, 0, 0, 0},
40662 { "GETNPCDATAHYOFS", 2, 0, 0, 0},
40663 { "GETNPCDATAHITWIDTH", 2, 0, 0, 0},
40664 { "GETNPCDATAHITHEIGHT", 2, 0, 0, 0},
40665 { "GETNPCDATAHITZ", 2, 0, 0, 0},
40666 { "GETNPCDATATILEWIDTH", 2, 0, 0, 0},
40667 { "GETNPCDATATILEHEIGHT", 2, 0, 0, 0},
40668 { "GETNPCDATAWPNSPRITE", 2, 0, 0, 0},
40669 //two inputs one return
40670 { "GETNPCDATASCRIPTDEF", 1, 0, 0, 0},
40671 { "GETNPCDATADEFENSE", 1, 0, 0, 0},
40672 { "GETNPCDATASIZEFLAG", 1, 0, 0, 0},
40673 { "GETNPCDATAATTRIBUTE", 1, 0, 0, 0},
40674 //two inputs no return
40675 { "SETNPCDATAFLAGS", 2, 0, 0, 0},
40676 { "SETNPCDATAFLAGS2", 2, 0, 0, 0},
40677 { "SETNPCDATAWIDTH", 2, 0, 0, 0},
40678 { "SETNPCDATAHEIGHT", 2, 0, 0, 0},
40679 { "SETNPCDATASTILE", 2, 0, 0, 0},
40680 { "SETNPCDATASWIDTH", 2, 0, 0, 0},
40681 { "SETNPCDATASHEIGHT", 2, 0, 0, 0},
40682 { "SETNPCDATAETILE", 2, 0, 0, 0},
40683 { "SETNPCDATAEWIDTH", 2, 0, 0, 0},
40684 { "SETNPCDATAHP", 2, 0, 0, 0},
40685 { "SETNPCDATAFAMILY", 2, 0, 0, 0},
40686 { "SETNPCDATACSET", 2, 0, 0, 0},
40687 { "SETNPCDATAANIM", 2, 0, 0, 0},
40688 { "SETNPCDATAEANIM", 2, 0, 0, 0},
40689 { "SETNPCDATAFRAMERATE", 2, 0, 0, 0},
40690 { "SETNPCDATAEFRAMERATE", 2, 0, 0, 0},
40691 { "SETNPCDATATOUCHDMG", 2, 0, 0, 0},
40692 { "SETNPCDATAWPNDAMAGE", 2, 0, 0, 0},
40693 { "SETNPCDATAWEAPON", 2, 0, 0, 0},
40694 { "SETNPCDATARANDOM", 2, 0, 0, 0},
40695 { "SETNPCDATAHALT", 2, 0, 0, 0},
40696 { "SETNPCDATASTEP", 2, 0, 0, 0},
40697 { "SETNPCDATAHOMING", 2, 0, 0, 0},
40698 { "SETNPCDATAHUNGER", 2, 0, 0, 0},
40699 { "SETNPCDATADROPSET", 2, 0, 0, 0},
40700 { "SETNPCDATABGSFX", 2, 0, 0, 0},
40701 { "SETNPCDATADEATHSFX", 2, 0, 0, 0},
40702 { "SETNPCDATAXOFS", 2, 0, 0, 0},
40703 { "SETNPCDATAYOFS", 2, 0, 0, 0},
40704 { "SETNPCDATAZOFS", 2, 0, 0, 0},
40705 { "SETNPCDATAHXOFS", 2, 0, 0, 0},
40706 { "SETNPCDATAHYOFS", 2, 0, 0, 0},
40707 { "SETNPCDATAHITWIDTH", 2, 0, 0, 0},
40708 { "SETNPCDATAHITHEIGHT", 2, 0, 0, 0},
40709 { "SETNPCDATAHITZ", 2, 0, 0, 0},
40710 { "SETNPCDATATILEWIDTH", 2, 0, 0, 0},
40711 { "SETNPCDATATILEHEIGHT", 2, 0, 0, 0},
40712 { "SETNPCDATAWPNSPRITE", 2, 0, 0, 0},
40713 { "SETNPCDATAHITSFX", 2, 0, 0, 0},
40714 { "GETNPCDATAHITSFX", 2, 0, 0, 0},
40715 //Combodata, one input no return
40716 { "GCDBLOCKENEM", 2, 0, 0, 0},
40717 { "GCDBLOCKHOLE", 2, 0, 0, 0},
40718 { "GCDBLOCKTRIG", 2, 0, 0, 0},
40719 { "GCDCONVEYSPDX", 2, 0, 0, 0},
40720 { "GCDCONVEYSPDY", 2, 0, 0, 0},
40721 { "GCDCREATEENEM", 2, 0, 0, 0},
40722 { "GCDCREATEENEMWH", 2, 0, 0, 0},
40723 { "GCDCREATEENEMCH", 2, 0, 0, 0},
40724 { "GCDDIRCHTYPE", 2, 0, 0, 0},
40725 { "GCDDISTCHTILES", 2, 0, 0, 0},
40726 { "GCDDIVEITEM", 2, 0, 0, 0},
40727 { "GCDDOCK", 2, 0, 0, 0},
40728 { "GCDFAIRY", 2, 0, 0, 0},
40729 { "GCDFFCOMBOATTRIB", 2, 0, 0, 0},
40730 { "GCDFOOTDECOTILE", 2, 0, 0, 0},
40731 { "GCDFOOTDECOTYPE", 2, 0, 0, 0},
40732 { "GCDHOOKSHOTGRAB", 2, 0, 0, 0},
40733 { "GCDLADDERPASS", 2, 0, 0, 0},
40734 { "GCDLOCKBLOCKTYPE", 2, 0, 0, 0},
40735 { "GCDLOCKBLOCKCHANGE", 2, 0, 0, 0},
40736 { "GCDMAGICMIRRORTYPE", 2, 0, 0, 0},
40737 { "GCDMODIFYHPAMOUNT", 2, 0, 0, 0},
40738 { "GCDMODIFYHPDELAY", 2, 0, 0, 0},
40739 { "GCDMODIFYHPTYPE", 2, 0, 0, 0},
40740 { "GCDMODIFYMPAMOUNT", 2, 0, 0, 0},
40741 { "GCDMODIFYMPDELAY", 2, 0, 0, 0},
40742 { "GCDMODIFYMPTYPE", 2, 0, 0, 0},
40743 { "GCDNOPUSHBLOCKS", 2, 0, 0, 0},
40744 { "GCDOVERHEAD", 2, 0, 0, 0},
40745 { "GCDPLACEENEMY", 2, 0, 0, 0},
40746 { "GCDPUSHDIR", 2, 0, 0, 0},
40747 { "GCDPUSHWEIGHT", 2, 0, 0, 0},
40748 { "GCDPUSHWAIT", 2, 0, 0, 0},
40749 { "GCDPUSHED", 2, 0, 0, 0},
40750 { "GCDRAFT", 2, 0, 0, 0},
40751 { "GCDRESETROOM", 2, 0, 0, 0},
40752 { "GCDSAVEPOINT", 2, 0, 0, 0},
40753 { "GCDSCREENFREEZE", 2, 0, 0, 0},
40754 { "GCDSECRETCOMBO", 2, 0, 0, 0},
40755 { "GCDSINGULAR", 2, 0, 0, 0},
40756 { "GCDSLOWMOVE", 2, 0, 0, 0},
40757 { "GCDSTATUE", 2, 0, 0, 0},
40758 { "GCDSTEPTYPE", 2, 0, 0, 0},
40759 { "GCDSTEPCHANGETO", 2, 0, 0, 0},
40760 { "GCDSTRIKEREMNANTS", 2, 0, 0, 0},
40761 { "GCDSTRIKEREMNANTSTYPE", 2, 0, 0, 0},
40762 { "GCDSTRIKECHANGE", 2, 0, 0, 0},
40763 { "GCDSTRIKECHANGEITEM", 2, 0, 0, 0},
40764 { "GCDTOUCHITEM", 2, 0, 0, 0},
40765 { "GCDTOUCHSTAIRS", 2, 0, 0, 0},
40766 { "GCDTRIGGERTYPE", 2, 0, 0, 0},
40767 { "GCDTRIGGERSENS", 2, 0, 0, 0},
40768 { "GCDWARPTYPE", 2, 0, 0, 0},
40769 { "GCDWARPSENS", 2, 0, 0, 0},
40770 { "GCDWARPDIRECT", 2, 0, 0, 0},
40771 { "GCDWARPLOCATION", 2, 0, 0, 0},
40772 { "GCDWATER", 2, 0, 0, 0},
40773 { "GCDWHISTLE", 2, 0, 0, 0},
40774 { "GCDWINGAME", 2, 0, 0, 0},
40775 { "GCDBLOCKWEAPLVL", 2, 0, 0, 0},
40776 { "GCDTILE", 2, 0, 0, 0},
40777 { "GCDFLIP", 2, 0, 0, 0},
40778 { "GCDWALK", 2, 0, 0, 0},
40779 { "GCDTYPE", 2, 0, 0, 0},
40780 { "GCDCSETS", 2, 0, 0, 0},
40781 { "GCDFOO", 2, 0, 0, 0},
40782 { "GCDFRAMES", 2, 0, 0, 0},
40783 { "GCDSPEED", 2, 0, 0, 0},
40784 { "GCDNEXTCOMBO", 2, 0, 0, 0},
40785 { "GCDNEXTCSET", 2, 0, 0, 0},
40786 { "GCDFLAG", 2, 0, 0, 0},
40787 { "GCDSKIPANIM", 2, 0, 0, 0},
40788 { "GCDNEXTTIMER", 2, 0, 0, 0},
40789 { "GCDSKIPANIMY", 2, 0, 0, 0},
40790 { "GCDANIMFLAGS", 2, 0, 0, 0},
40791 //combodata two input, one return
40792 { "GCDBLOCKWEAPON", 1, 0, 0, 0},
40793 { "GCDEXPANSION", 1, 0, 0, 0},
40794 { "GCDSTRIKEWEAPONS", 1, 0, 0, 0},
40795 //combodata two input, one return
40796 { "SCDBLOCKENEM", 2, 0, 0, 0},
40797 { "SCDBLOCKHOLE", 2, 0, 0, 0},
40798 { "SCDBLOCKTRIG", 2, 0, 0, 0},
40799 { "SCDCONVEYSPDX", 2, 0, 0, 0},
40800 { "SCDCONVEYSPDY", 2, 0, 0, 0},
40801 { "SCDCREATEENEM", 2, 0, 0, 0},
40802 { "SCDCREATEENEMWH", 2, 0, 0, 0},
40803 { "SCDCREATEENEMCH", 2, 0, 0, 0},
40804 { "SCDDIRCHTYPE", 2, 0, 0, 0},
40805 { "SCDDISTCHTILES", 2, 0, 0, 0},
40806 { "SCDDIVEITEM", 2, 0, 0, 0},
40807 { "SCDDOCK", 2, 0, 0, 0},
40808 { "SCDFAIRY", 2, 0, 0, 0},
40809 { "SCDFFCOMBOATTRIB", 2, 0, 0, 0},
40810 { "SCDFOOTDECOTILE", 2, 0, 0, 0},
40811 { "SCDFOOTDECOTYPE", 2, 0, 0, 0},
40812 { "SCDHOOKSHOTGRAB", 2, 0, 0, 0},
40813 { "SCDLADDERPASS", 2, 0, 0, 0},
40814 { "SCDLOCKBLOCKTYPE", 2, 0, 0, 0},
40815 { "SCDLOCKBLOCKCHANGE", 2, 0, 0, 0},
40816 { "SCDMAGICMIRRORTYPE", 2, 0, 0, 0},
40817 { "SCDMODIFYHPAMOUNT", 2, 0, 0, 0},
40818 { "SCDMODIFYHPDELAY", 2, 0, 0, 0},
40819 { "SCDMODIFYHPTYPE", 2, 0, 0, 0},
40820 { "SCDMODIFYMPAMOUNT", 2, 0, 0, 0},
40821 { "SCDMODIFYMPDELAY", 2, 0, 0, 0},
40822 { "SCDMODIFYMPTYPE", 2, 0, 0, 0},
40823 { "SCDNOPUSHBLOCKS", 2, 0, 0, 0},
40824 { "SCDOVERHEAD", 2, 0, 0, 0},
40825 { "SCDPLACEENEMY", 2, 0, 0, 0},
40826 { "SCDPUSHDIR", 2, 0, 0, 0},
40827 { "SCDPUSHWEIGHT", 2, 0, 0, 0},
40828 { "SCDPUSHWAIT", 2, 0, 0, 0},
40829 { "SCDPUSHED", 2, 0, 0, 0},
40830 { "SCDRAFT", 2, 0, 0, 0},
40831 { "SCDRESETROOM", 2, 0, 0, 0},
40832 { "SCDSAVEPOINT", 2, 0, 0, 0},
40833 { "SCDSCREENFREEZE", 2, 0, 0, 0},
40834 { "SCDSECRETCOMBO", 2, 0, 0, 0},
40835 { "SCDSINGULAR", 2, 0, 0, 0},
40836 { "SCDSLOWMOVE", 2, 0, 0, 0},
40837 { "SCDSTATUE", 2, 0, 0, 0},
40838 { "SCDSTEPTYPE", 2, 0, 0, 0},
40839 { "SCDSTEPCHANGETO", 2, 0, 0, 0},
40840 { "SCDSTRIKEREMNANTS", 2, 0, 0, 0},
40841 { "SCDSTRIKEREMNANTSTYPE", 2, 0, 0, 0},
40842 { "SCDSTRIKECHANGE", 2, 0, 0, 0},
40843 { "SCDSTRIKECHANGEITEM", 2, 0, 0, 0},
40844 { "SCDTOUCHITEM", 2, 0, 0, 0},
40845 { "SCDTOUCHSTAIRS", 2, 0, 0, 0},
40846 { "SCDTRIGGERTYPE", 2, 0, 0, 0},
40847 { "SCDTRIGGERSENS", 2, 0, 0, 0},
40848 { "SCDWARPTYPE", 2, 0, 0, 0},
40849 { "SCDWARPSENS", 2, 0, 0, 0},
40850 { "SCDWARPDIRECT", 2, 0, 0, 0},
40851 { "SCDWARPLOCATION", 2, 0, 0, 0},
40852 { "SCDWATER", 2, 0, 0, 0},
40853 { "SCDWHISTLE", 2, 0, 0, 0},
40854 { "SCDWINGAME", 2, 0, 0, 0},
40855 { "SCDBLOCKWEAPLVL", 2, 0, 0, 0},
40856 { "SCDTILE", 2, 0, 0, 0},
40857 { "SCDFLIP", 2, 0, 0, 0},
40858 { "SCDWALK", 2, 0, 0, 0},
40859 { "SCDTYPE", 2, 0, 0, 0},
40860 { "SCDCSETS", 2, 0, 0, 0},
40861 { "SCDFOO", 2, 0, 0, 0},
40862 { "SCDFRAMES", 2, 0, 0, 0},
40863 { "SCDSPEED", 2, 0, 0, 0},
40864 { "SCDNEXTCOMBO", 2, 0, 0, 0},
40865 { "SCDNEXTCSET", 2, 0, 0, 0},
40866 { "SCDFLAG", 2, 0, 0, 0},
40867 { "SCDSKIPANIM", 2, 0, 0, 0},
40868 { "SCDNEXTTIMER", 2, 0, 0, 0},
40869 { "SCDSKIPANIMY", 2, 0, 0, 0},
40870 { "SCDANIMFLAGS", 2, 0, 0, 0},
40871 { "GETNPCDATATILE", 2, 0, 0, 0},
40872 { "GETNPCDATAEHEIGHT", 2, 0, 0, 0},
40873 { "SETNPCDATATILE", 2, 0, 0, 0},
40874 { "SETNPCDATAEHEIGHT", 2, 0, 0, 0},
40875 { "GETSPRITEDATASTRING", 2, 0, 0, 0},
40876 //SpriteData
40877 { "GETSPRITEDATATILE", 2, 0, 0, 0},
40878 { "GETSPRITEDATAMISC", 2, 0, 0, 0},
40879 { "GETSPRITEDATACGETS", 2, 0, 0, 0},
40880 { "GETSPRITEDATAFRAMES", 2, 0, 0, 0},
40881 { "GETSPRITEDATASPEED", 2, 0, 0, 0},
40882 { "GETSPRITEDATATYPE", 2, 0, 0, 0},
40883 { "SETSPRITEDATASTRING", 2, 0, 0, 0},
40884 { "SETSPRITEDATATILE", 2, 0, 0, 0},
40885 { "SETSPRITEDATAMISC", 2, 0, 0, 0},
40886 { "SETSPRITEDATACSETS", 2, 0, 0, 0},
40887 { "SETSPRITEDATAFRAMES", 2, 0, 0, 0},
40888 { "SETSPRITEDATASPEED", 2, 0, 0, 0},
40889 { "SETSPRITEDATATYPE", 2, 0, 0, 0},
40890 //Game->SetContinueScreenSetting
40891 { "SETCONTINUESCREEN", 2, 0, 0, 0},
40892 //Game->SetContinueScreenString
40893 { "SETCONTINUESTRING", 2, 0, 0, 0},
40894
40895 { "LOADNPCDATAR", 1, 0, 0, 0},
40896 { "LOADNPCDATAV", 1, 1, 0, 0},
40897
40898 { "LOADCOMBODATAR", 1, 0, 0, 0},
40899 { "LOADCOMBODATAV", 1, 1, 0, 0},
40900
40901 { "LOADMAPDATAR", 1, 0, 0, 0},
40902 { "LOADMAPDATAV", 1, 1, 0, 0},
40903
40904 { "LOADSPRITEDATAR", 1, 0, 0, 0},
40905 { "LOADSPRITEDATAV", 1, 1, 0, 0},
40906
40907 { "LOADSCREENDATAR", 1, 0, 0, 0},
40908 { "LOADSCREENDATAV", 1, 1, 0, 0},
40909
40910 { "LOADBITMAPDATAR", 1, 0, 0, 0},
40911 { "LOADBITMAPDATAV", 1, 1, 0, 0},
40912
40913 { "LOADSHOPR", 1, 0, 0, 0},
40914 { "LOADSHOPV", 1, 1, 0, 0},
40915
40916 { "LOADINFOSHOPR", 1, 0, 0, 0},
40917 { "LOADINFOSHOPV", 1, 1, 0, 0},
40918
40919 { "LOADMESSAGEDATAR", 1, 0, 0, 0},
40920 { "LOADMESSAGEDATAV", 1, 1, 0, 0},
40921 { "MESSAGEDATASETSTRINGR", 1, 0, 0, 0},
40922 { "MESSAGEDATASETSTRINGV", 1, 1, 0, 0},
40923 { "MESSAGEDATAGETSTRINGR", 1, 0, 0, 0},
40924 { "MESSAGEDATAGETSTRINGV", 1, 1, 0, 0},
40925
40926 { "LOADDMAPDATAR", 1, 0, 0, 0},
40927 { "LOADDMAPDATAV", 1, 1, 0, 0},
40928 { "DMAPDATAGETNAMER", 1, 0, 0, 0},
40929 { "DMAPDATAGETNAMEV", 1, 1, 0, 0},
40930 { "DMAPDATASETNAMER", 1, 0, 0, 0},
40931 { "DMAPDATASETNAMEV", 1, 1, 0, 0},
40932 { "DMAPDATAGETTITLER", 1, 0, 0, 0},
40933 { "DMAPDATAGETTITLEV", 1, 1, 0, 0},
40934 { "DMAPDATASETTITLER", 1, 0, 0, 0},
40935 { "DMAPDATASETTITLEV", 1, 1, 0, 0},
40936
40937 { "DMAPDATAGETINTROR", 1, 0, 0, 0},
40938 { "DMAPDATAGETINTROV", 1, 1, 0, 0},
40939 { "DMAPDATANSETITROR", 1, 0, 0, 0},
40940 { "DMAPDATASETINTROV", 1, 1, 0, 0},
40941 { "DMAPDATAGETMUSICR", 1, 0, 0, 0},
40942 { "DMAPDATAGETMUSICV", 1, 1, 0, 0},
40943 { "DMAPDATASETMUSICR", 1, 0, 0, 0},
40944 { "DMAPDATASETMUSICV", 1, 1, 0, 0},
40945
40946 { "ADJUSTSFXVOLUMER", 1, 0, 0, 0},
40947 { "ADJUSTSFXVOLUMEV", 1, 1, 0, 0},
40948
40949 { "ADJUSTVOLUMER", 1, 0, 0, 0},
40950 { "ADJUSTVOLUMEV", 1, 1, 0, 0},
40951
40952 { "FXWAVYR", 1, 0, 0, 0},
40953 { "FXWAVYV", 1, 1, 0, 0},
40954
40955 { "FXZAPR", 1, 0, 0, 0},
40956 { "FXZAPV", 1, 1, 0, 0},
40957
40958 { "GREYSCALER", 1, 0, 0, 0},
40959 { "GREYSCALEV", 1, 1, 0, 0},
40960 { "RETURN", 0, 0, 0, 0},
40961 { "MONOCHROMER", 1, 0, 0, 0},
40962 { "MONOCHROMEV", 1, 1, 0, 0},
40963 { "CLEARTINT", 0, 0, 0, 0},
40964 { "TINT", 0, 0, 0, 0},
40965 { "MONOHUE", 0, 0, 0, 0},
40966
40967 { "BMPRECTR", 0, 0, 0, 0},
40968 { "BMPCIRCLER", 0, 0, 0, 0},
40969 { "BMPARCR", 0, 0, 0, 0},
40970 { "BMPELLIPSER", 0, 0, 0, 0},
40971 { "BMPLINER", 0, 0, 0, 0},
40972 { "BMPSPLINER", 0, 0, 0, 0},
40973 { "BMPPUTPIXELR", 0, 0, 0, 0},
40974 { "BMPDRAWTILER", 0, 0, 0, 0},
40975 { "BMPDRAWCOMBOR", 0, 0, 0, 0},
40976 { "BMPFASTTILER", 0, 0, 0, 0},
40977 { "BMPFASTCOMBOR", 0, 0, 0, 0},
40978 { "BMPDRAWCHARR", 0, 0, 0, 0},
40979 { "BMPDRAWINTR", 0, 0, 0, 0},
40980 { "BMPDRAWSTRINGR", 0, 0, 0, 0},
40981 { "BMPQUADR", 0, 0, 0, 0},
40982 { "BMPQUAD3DR", 0, 0, 0, 0},
40983 { "BMPTRIANGLER", 0, 0, 0, 0},
40984 { "BMPTRIANGLE3DR", 0, 0, 0, 0},
40985 { "BMPPOLYGONR", 0, 0, 0, 0},
40986 { "BMPDRAWLAYERR", 0, 0, 0, 0},
40987 { "BMPDRAWSCREENR", 0, 0, 0, 0},
40988 { "BMPBLIT", 0, 0, 0, 0},
40989
40990 { "LINKWARPEXR", 1, 0, 0, 0},
40991 { "LINKWARPEXV", 1, 1, 0, 0},
40992 { "LINKEXPLODER", 1, 0, 0, 0},
40993 { "LINKEXPLODEV", 1, 1, 0, 0},
40994 { "NPCEXPLODER", 1, 0, 0, 0},
40995 { "NPCEXPLODEV", 1, 1, 0, 0},
40996
40997 { "ITEMEXPLODER", 1, 0, 0, 0},
40998 { "ITEMEXPLODEV", 1, 1, 0, 0},
40999 { "LWEAPONEXPLODER", 1, 0, 0, 0},
41000 { "LWEAPONEXPLODEV", 1, 1, 0, 0},
41001 { "EWEAPONEXPLODER", 1, 0, 0, 0},
41002 { "EWEAPONEXPLODEV", 1, 1, 0, 0},
41003 { "RUNITEMSCRIPT", 0, 0, 0, 0},
41004 { "GETRTCTIMER", 1, 0, 0, 0},
41005 { "GETRTCTIMEV", 1, 1, 0, 0},
41006
41007 //new npc functions for npc scripts
41008 { "NPCDEAD", 1, 0, 0, 0},
41009 { "NPCKICKBUCKET", 0, 0, 0, 0},
41010 { "NPCSTOPBGSFX", 0, 0, 0, 0},
41011 { "NPCCANMOVE", 1, 0, 0, 0},
41012 { "NPCNEWDIR8", 0, 0, 0, 0},
41013 { "NPCNEWDIR", 0, 0, 0, 0},
41014 { "NPCCONSTWALK", 0, 0, 0, 0},
41015 { "NPCCONSTWALK8", 0, 0, 0, 0},
41016 { "NPCVARWALK", 0, 0, 0, 0},
41017 { "NPCVARWALK8", 0, 0, 0, 0},
41018 { "NPCHALTWALK", 0, 0, 0, 0},
41019 { "NPCHALTWALK8", 0, 0, 0, 0},
41020 { "NPCFLOATWALK", 0, 0, 0, 0},
41021 // moved to a var: { "NPCLINEDUP", 0, 0, 0, 0},
41022 { "NPCLINKINRANGE", 1, 0, 0, 0},
41023 { "NPCATTACK", 0, 0, 0, 0},
41024 { "NPCPLACEONAXIS", 0, 0, 0, 0},
41025 { "NPCADD", 1, 0, 0, 0},
41026 { "NPCFIREBREATH", 0, 0, 0, 0},
41027 { "NPCCANSLIDE", 1, 0, 0, 0},
41028 { "NPCSLIDE", 1, 0, 0, 0},
41029 { "NPCHITWITH", 1, 0, 0, 0},
41030 { "NPCGETINITDLABEL", 0, 0, 0, 0},
41031 // moved to a var: { "NPCCOLLISION", 0, 0, 0, 0}, //how to implement this?
41032 { "GAMECONTINUE", 0, 0, 0, 0},
41033 { "MAPDATAISSOLID", 1, 0, 0, 0},
41034 { "SHOWF6SCREEN", 0, 0, 0, 0},
41035 { "NPCDATAGETNAME", 1, 0, 0, 0},
41036 { "PLAYENHMUSICEX", 2, 0, 0, 0},
41037 { "GETENHMUSICPOS", 1, 0, 0, 0},
41038 { "SETENHMUSICPOS", 1, 0, 0, 0},
41039 { "SETENHMUSICSPEED", 1, 0, 0, 0},
41040 { "ISVALIDBITMAP", 1, 0, 0, 0},
41041 { "READBITMAP", 0, 0, 0, 0},
41042 { "WRITEBITMAP", 0, 0, 0, 0},
41043 { "ALLOCATEBITMAP", 1, 0, 0, 0},
41044 { "CLEARBITMAP", 0, 0, 0, 0},
41045 { "REGENERATEBITMAP", 0, 0, 0, 0},
41046 { "BMPBLITTO", 0, 0, 0, 0},
41047
41048 { "BMPDRAWSCREENSOLIDR", 0, 0, 0, 0},
41049 { "BMPDRAWSCREENCOMBOFR", 0, 0, 0, 0},
41050 { "BMPDRAWSCREENCOMBOIR", 0, 0, 0, 0},
41051 { "BMPDRAWSCREENCOMBOTR", 0, 0, 0, 0},
41052 { "BMPDRAWSCREENSOLID2R", 0, 0, 0, 0},
41053 { "GRAPHICSGETPIXEL", 1, 0, 0, 0},
41054
41055 { "BMPDRAWLAYERSOLIDR", 0, 0, 0, 0},
41056 { "BMPDRAWLAYERCFLAGR", 0, 0, 0, 0},
41057 { "BMPDRAWLAYERCTYPER", 0, 0, 0, 0},
41058 { "BMPDRAWLAYERCIFLAGR", 0, 0, 0, 0},
41059 { "BMPDRAWLAYERSOLIDITYR", 0, 0, 0, 0},
41060 { "BMPMODE7", 0, 0, 0, 0},
41061 { "BITMAPGETPIXEL", 0, 0, 0, 0},
41062 { "NOP", 0, 0, 0, 0},
41063 { "STRINGCOMPARE", 1, 0, 0, 0},
41064 { "STRINGNCOMPARE", 1, 0, 0, 0},
41065 { "STRINGLENGTH", 2, 0, 0, 0},
41066 { "STRINGCOPY", 2, 0, 0, 0},
41067 { "CASTBOOLI", 1, 0, 0, 0},
41068 { "CASTBOOLF", 1, 0, 0, 0},
41069 { "SETTRUEI", 1, 0, 0, 0},
41070 { "SETFALSEI", 1, 0, 0, 0},
41071 { "SETMOREI", 1, 0, 0, 0},
41072 { "SETLESSI", 1, 0, 0, 0},
41073
41074 { "ARRAYCOPY", 2, 0, 0, 0},
41075 { "ARRAYNCOPY", 1, 0, 0, 0},
41076
41077 //1 INPUT, NO RETURN
41078 { "REMCHR", 2, 0, 0, 0},
41079 { "STRINGUPPERLOWER", 2, 0, 0, 0},
41080 { "STRINGLOWERUPPER", 2, 0, 0, 0},
41081 { "STRINGCONVERTCASE", 2, 0, 0, 0},
41082
41083 //1 input, 1 ret
41084 { "XLEN", 2, 0, 0, 0},
41085 { "XTOI", 2, 0, 0, 0},
41086 { "ILEN", 2, 0, 0, 0},
41087 { "ATOI", 2, 0, 0, 0},
41088
41089 //2 INPUT, 1 RET, based on strcmp
41090 { "STRCSPN", 1, 0, 0, 0},
41091 { "STRSTR", 1, 0, 0, 0},
41092 { "XTOA", 2, 0, 0, 0},
41093 { "ITOA", 2, 0, 0, 0},
41094 { "STRCAT", 1, 0, 0, 0},
41095 { "STRSPN", 1, 0, 0, 0},
41096 { "STRCHR", 1, 0, 0, 0},
41097 { "STRRCHR", 1, 0, 0, 0},
41098 //2 INP, 1 RET OVERLOADS
41099 { "XLEN2", 1, 0, 0, 0},
41100 { "XTOI2", 1, 0, 0, 0},
41101 { "ILEN2", 1, 0, 0, 0},
41102 { "ATOI2", 1, 0, 0, 0},
41103 { "REMCHR2", 1, 0, 0, 0},
41104
41105 //3 INPUT 1 RET
41106 { "XTOA3", 1, 0, 0, 0},
41107 { "STRCATF", 1, 0, 0, 0},
41108 { "ITOA3", 1, 0, 0, 0},
41109 { "STRSTR3", 1, 0, 0, 0},
41110 { "REMNCHR3", 1, 0, 0, 0},
41111 { "STRCAT3", 1, 0, 0, 0},
41112 { "STRNCAT3", 1, 0, 0, 0},
41113 { "STRCHR3", 1, 0, 0, 0},
41114 { "STRRCHR3", 1, 0, 0, 0},
41115 { "STRSPN3", 1, 0, 0, 0},
41116 { "STRCSPN3", 1, 0, 0, 0},
41117
41118
41119 { "UPPERTOLOWER", 2, 0, 0, 0},
41120 { "LOWERTOUPPER", 2, 0, 0, 0},
41121 { "CONVERTCASE", 2, 0, 0, 0},
41122 //Game->Get
41123 { "GETNPCSCRIPT", 1, 0, 0, 0},
41124 { "GETLWEAPONSCRIPT", 1, 0, 0, 0},
41125 { "GETEWEAPONSCRIPT", 1, 0, 0, 0},
41126 { "GETHEROSCRIPT", 1, 0, 0, 0},
41127 { "GETGLOBALSCRIPT", 1, 0, 0, 0},
41128 { "GETDMAPSCRIPT", 1, 0, 0, 0},
41129 { "GETSCREENSCRIPT", 1, 0, 0, 0},
41130 { "GETSPRITESCRIPT", 1, 0, 0, 0},
41131 { "GETUNTYPEDSCRIPT", 1, 0, 0, 0},
41132 { "GETSUBSCREENSCRIPT", 1, 0, 0, 0},
41133 { "GETNPCBYNAME", 1, 0, 0, 0},
41134 { "GETITEMBYNAME", 1, 0, 0, 0},
41135 { "GETCOMBOBYNAME", 1, 0, 0, 0},
41136 { "GETDMAPBYNAME", 1, 0, 0, 0},
41137
41138 { "SRNDR", 1, 0, 0, 0},
41139 { "SRNDV", 1, 1, 0, 0},
41140 { "SRNDRND", 1, 0, 0, 0},
41141 { "SAVEGAMESTRUCTS", 2, 0, 0, 0},
41142 { "READGAMESTRUCTS", 2, 0, 0, 0},
41143 { "ANDR32", 2, 0, 0, 0},
41144 { "ANDV32", 2, 0, 1, 0},
41145 { "ORR32", 2, 0, 0, 0},
41146 { "ORV32", 2, 0, 1, 0},
41147 { "XORR32", 2, 0, 0, 0},
41148 { "XORV32", 2, 0, 1, 0},
41149 { "BITNOT32", 1, 0, 0, 0},
41150 { "LSHIFTR32", 2, 0, 0, 0},
41151 { "LSHIFTV32", 2, 0, 1, 0},
41152 { "RSHIFTR32", 2, 0, 0, 0},
41153 { "RSHIFTV32", 2, 0, 1, 0},
41154 { "ISALLOCATEDBITMAP", 1, 0, 0, 0},
41155 { "FONTHEIGHTR", 1, 0, 0, 0},
41156 { "STRINGWIDTHR", 2, 0, 0, 0},
41157 { "CHARWIDTHR", 2, 0, 0, 0},
41158 { "MESSAGEWIDTHR", 1, 0, 0, 0},
41159 { "MESSAGEHEIGHTR", 1, 0, 0, 0},
41160 { "ISVALIDARRAY", 1, 0, 0, 0},
41161 { "DIREXISTS", 1, 0, 0, 0},
41162 { "GAMESAVEQUIT", 0, 0, 0, 0},
41163 { "GAMESAVECONTINUE", 0, 0, 0, 0},
41164 { "DRAWTILECLOAKEDR", 0, 0, 0, 0},
41165 { "BMPDRAWTILECLOAKEDR", 0, 0, 0, 0},
41166 { "DRAWCOMBOCLOAKEDR", 0, 0, 0, 0},
41167 { "BMPDRAWCOMBOCLOAKEDR", 0, 0, 0, 0},
41168 { "NPCKNOCKBACK", 2, 0, 0, 0},
41169 { "CLOSEWIPE", 0, 0, 0, 0},
41170 { "OPENWIPESHAPE", 1, 0, 0, 0},
41171 { "CLOSEWIPESHAPE", 1, 0, 0, 0},
41172 { "FILEEXISTS", 1, 0, 0, 0},
41173 { "BITMAPCLEARTOCOLOR", 0, 0, 0, 0},
41174 { "LOADNPCBYSUID", 1, 0, 0, 0},
41175 { "LOADLWEAPONBYSUID", 1, 0, 0, 0},
41176 { "LOADWEAPONCBYSUID", 1, 0, 0, 0},
41177 { "LOADDROPSETR", 1, 0, 0, 0},
41178 { "LOADTMPSCR", 1, 0, 0, 0},
41179 { "LOADSCROLLSCR", 1, 0, 0, 0},
41180 { "MAPDATAISSOLIDLYR", 1, 0, 0, 0},
41181 { "ISSOLIDLAYER", 1, 0, 0, 0},
41182 { "BREAKPOINT", 1, 0, 0, 0},
41183 { "TOBYTE", 1, 0, 0, 0},
41184 { "TOWORD", 1, 0, 0, 0},
41185 { "TOSHORT", 1, 0, 0, 0},
41186 { "TOSIGNEDBYTE", 1, 0, 0, 0},
41187 { "TOINTEGER", 1, 0, 0, 0},
41188 { "FLOOR", 1, 0, 0, 0},
41189 { "CEILING", 1, 0, 0, 0},
41190
41191 { "FILECLOSE", 0, 0, 0, 0},
41192 { "FILEFREE", 0, 0, 0, 0},
41193 { "FILEISALLOCATED", 0, 0, 0, 0},
41194 { "FILEISVALID", 0, 0, 0, 0},
41195 { "FILEALLOCATE", 0, 0, 0, 0},
41196 { "FILEFLUSH", 0, 0, 0, 0},
41197 { "FILEGETCHAR", 0, 0, 0, 0},
41198 { "FILEREWIND", 0, 0, 0, 0},
41199 { "FILECLEARERR", 0, 0, 0, 0},
41200
41201 { "FILEOPEN", 1, 0, 0, 0},
41202 { "FILECREATE", 1, 0, 0, 0},
41203 { "FILEREADSTR", 1, 0, 0, 0},
41204 { "FILEWRITESTR", 1, 0, 0, 0},
41205 { "FILEPUTCHAR", 1, 0, 0, 0},
41206 { "FILEUNGETCHAR", 1, 0, 0, 0},
41207
41208 { "FILEREADCHARS", 2, 0, 0, 0},
41209 { "FILEREADINTS", 2, 0, 0, 0},
41210 { "FILEWRITECHARS", 2, 0, 0, 0},
41211 { "FILEWRITEINTS", 2, 0, 0, 0},
41212 { "FILESEEK", 2, 0, 0, 0},
41213 { "FILEOPENMODE", 2, 0, 0, 0},
41214 { "FILEGETERROR", 1, 0, 0, 0},
41215
41216 { "BITMAPFREE", 0, 0, 0, 0},
41217
41218 { "POPARGS", 2, 0, 1, 0},
41219 { "GAMERELOAD", 0, 0, 0, 0},
41220
41221 { "READPODARRAYR", 2, 0, 0, 0},
41222 { "READPODARRAYV", 2, 0, 1, 0},
41223 { "WRITEPODARRAYRR", 2, 0, 0, 0},
41224 { "WRITEPODARRAYRV", 2, 0, 1, 0},
41225 { "WRITEPODARRAYVR", 2, 1, 0, 0},
41226 { "WRITEPODARRAYVV", 2, 1, 1, 0},
41227
41228 { "PRINTFV", 1, 1, 0, 0},
41229 { "SPRINTFV", 1, 1, 0, 0},
41230
41231 { "STRCMPR", 2, 0, 0, 0},
41232 { "STRICMPR", 2, 0, 0, 0},
41233 { "STRINGICOMPARE", 1, 0, 0, 0},
41234 { "STRINGNICOMPARE", 1, 0, 0, 0},
41235
41236 { "FILEREMOVE", 0, 0, 0, 0},
41237 { "FILESYSREMOVE", 1, 0, 0, 0},
41238
41239 { "DRAWSTRINGR2", 0, 0, 0, 0},
41240 { "BMPDRAWSTRINGR2", 0, 0, 0, 0},
41241
41242 { "MODULEGETIC", 2, 0, 0, 0},
41243 { "ITOACAT", 2, 0, 0, 0},
41244
41245 { "FRAMER", 0, 0, 0, 0},
41246 { "BMPFRAMER", 0, 0, 0, 0},
41247
41248 { "LOADDIRECTORYR", 1, 0, 0, 0},
41249 { "DIRECTORYGET", 2, 0, 0, 0},
41250 { "DIRECTORYRELOAD", 0, 0, 0, 0},
41251 { "DIRECTORYFREE", 0, 0, 0, 0},
41252 { "FILEWRITEBYTES", 2, 0, 0, 0},
41253 { "GETCOMBOSCRIPT", 1, 0, 0, 0},
41254 { "FILEREADBYTES", 2, 0, 0, 0},
41255
41256 { "LOADRNG", 0, 0, 0, 0},
41257 { "RNGRAND1", 0, 0, 0, 0},
41258 { "RNGRAND2", 1, 0, 0, 0},
41259 { "RNGRAND3", 2, 0, 0, 0},
41260 { "RNGLRAND1", 0, 0, 0, 0},
41261 { "RNGLRAND2", 1, 0, 0, 0},
41262 { "RNGLRAND3", 2, 0, 0, 0},
41263 { "RNGSEED", 1, 0, 0, 0},
41264 { "RNGRSEED", 0, 0, 0, 0},
41265 { "RNGFREE", 0, 0, 0, 0},
41266 { "LWPNDEL", 0, 0, 0, 0},
41267 { "EWPNDEL", 0, 0, 0, 0},
41268 { "ITEMDEL", 0, 0, 0, 0},
41269 { "BMPWRITETILE", 0, 0, 0, 0},
41270 { "BMPDITHER", 0, 0, 0, 0},
41271 { "BMPREPLCOLOR", 0, 0, 0, 0},
41272 { "BMPSHIFTCOLOR", 0, 0, 0, 0},
41273 { "BMPMASKDRAW", 0, 0, 0, 0},
41274 { "RESIZEARRAYR", 2, 0, 0, 0},
41275 { "BSHOPNAMEGET", 1, 0, 0, 0},
41276 { "BSHOPNAMESET", 1, 0, 0, 0},
41277 { "BOTTLENAMEGET", 1, 0, 0, 0},
41278 { "BOTTLENAMESET", 1, 0, 0, 0},
41279 { "LOADBOTTLETYPE", 1, 0, 0, 0},
41280 { "LOADBSHOPDATA", 1, 0, 0, 0},
41281 { "SWITCHNPC", 1, 0, 0, 0},
41282 { "SWITCHCMB", 2, 0, 0, 0},
41283 { "SWITCHITM", 1, 0, 0, 0},
41284 { "SWITCHLW", 1, 0, 0, 0},
41285 { "SWITCHEW", 1, 0, 0, 0},
41286 { "SCREENDOSPAWN", 0, 0, 0, 0},
41287 { "NPCMOVEPAUSED", 0, 0, 0, 0},
41288 { "NPCMOVE", 0, 0, 0, 0},
41289 { "NPCMOVEANGLE", 0, 0, 0, 0},
41290 { "NPCMOVEXY", 0, 0, 0, 0},
41291 { "NPCCANMOVEDIR", 0, 0, 0, 0},
41292 { "NPCCANMOVEANGLE", 0, 0, 0, 0},
41293 { "NPCCANMOVEXY", 0, 0, 0, 0},
41294 { "SELECTXWPNR", 1, 0, 0, 0},
41295 { "SELECTYWPNR", 1, 0, 0, 0},
41296 { "BITMAPOWN", 0, 0, 0, 0},
41297 { "FILEOWN", 0, 0, 0, 0},
41298 { "DIRECTORYOWN", 0, 0, 0, 0},
41299 { "RNGOWN", 0, 0, 0, 0},
41300 { "LOADGENERICDATA", 1, 0, 0, 0},
41301 { "RUNGENFRZSCR", 1, 0, 0, 0},
41302 { "WAITTO", 2, 0, 0, 0},
41303 { "GETGENERICSCRIPT", 1, 0, 0, 0},
41304 { "KILLPLAYER", 1, 0, 0, 0},
41305 { "DEGTORAD", 2, 0, 0, 0},
41306 { "RADTODEG", 2, 0, 0, 0},
41307 { "LWPNMAKEANGULAR", 1, 0, 0, 0},
41308 { "EWPNMAKEANGULAR", 1, 0, 0, 0},
41309 { "LWPNMAKEDIRECTIONAL", 1, 0, 0, 0},
41310 { "EWPNMAKEDIRECTIONAL", 1, 0, 0, 0},
41311 { "BMPMASKDRAW2", 0, 0, 0, 0},
41312 { "BMPMASKDRAW3", 0, 0, 0, 0},
41313 { "BMPMASKBLIT", 0, 0, 0, 0},
41314 { "BMPMASKBLIT2", 0, 0, 0, 0},
41315 { "BMPMASKBLIT3", 0, 0, 0, 0},
41316 { "SUBV2", 2, 1, 0, 0},
41317 { "DIVV2", 2, 1, 0, 0},
41318 { "COMPAREV2", 2, 1, 0, 0},
41319 { "MODV2", 2, 1, 0, 0},
41320 { "STACKFREE", 0, 0, 0, 0},
41321 { "STACKOWN", 0, 0, 0, 0},
41322 { "STACKGET", 1, 0, 0, 0},
41323 { "STACKSET", 2, 0, 0, 0},
41324 { "STACKPOPBACK", 0, 0, 0, 0},
41325 { "STACKPOPFRONT", 0, 0, 0, 0},
41326 { "STACKPEEKBACK", 0, 0, 0, 0},
41327 { "STACKPEEKFRONT", 0, 0, 0, 0},
41328 { "STACKPUSHBACK", 1, 0, 0, 0},
41329 { "STACKPUSHFRONT", 1, 0, 0, 0},
41330 { "LOADSTACK", 0, 0, 0, 0},
41331 { "STACKCLEAR", 0, 0, 0, 0},
41332 { "POWERV2", 2, 1, 0, 0},
41333 { "LPOWERR", 2, 0, 0, 0},
41334 { "LPOWERV", 2, 0, 1, 0},
41335 { "LPOWERV2", 2, 1, 0, 0},
41336 { "SCRTRIGGERCOMBO", 2, 0, 0, 0},
41337 { "WAITEVENT", 0, 0, 0, 0},
41338 { "OWNARRAYR", 1, 0, 0, 0},
41339 { "DESTROYARRAYR", 1, 0, 0, 0},
41340 { "GRAPHICSCOUNTCOLOR", 1, 0, 0, 0},
41341 { "WRITEPODSTRING", 1, 0, 0, 1},
41342 { "WRITEPODARRAY", 1, 0, 0, 2},
41343 { "ZCLASS_CONSTRUCT", 1, 0, 0, 2},
41344 { "ZCLASS_READ", 2, 0, 1, 0},
41345 { "ZCLASS_WRITE", 2, 0, 1, 0},
41346 { "ZCLASS_FREE", 1, 0, 0, 0},
41347 { "ZCLASS_OWN", 1, 0, 0, 0},
41348 { "STARTDESTRUCTOR", 0, 0, 0, 1},
41349 { "ZCLASS_GLOBALIZE", 1, 0, 0, 0},
41350 { "LOADD", 2, 0, 1, 0},
41351 { "STORED", 2, 0, 1, 0},
41352 { "OBJ_OWN_BITMAP", 2, 0, 1, 0},
41353 { "OBJ_OWN_PALDATA", 2, 0, 1, 0},
41354 { "OBJ_OWN_FILE", 2, 0, 1, 0},
41355 { "OBJ_OWN_DIR", 2, 0, 1, 0},
41356 { "OBJ_OWN_STACK", 2, 0, 1, 0},
41357 { "OBJ_OWN_RNG", 2, 0, 1, 0},
41358 { "OBJ_OWN_CLASS", 2, 0, 1, 0},
41359 { "OBJ_OWN_ARRAY", 2, 0, 1, 0},
41360 { "QUIT_NO_DEALLOC", 0, 0, 0, 0},
41361 { "GAMESETCUSTOMCURSOR", 0, 0, 0, 0},
41362 { "NPCCANPLACE", 0, 0, 0, 0},
41363 { "ITEMGETDISPLAYNAME", 1, 0, 0, 0},
41364 { "ITEMSETDISPLAYNAME", 1, 0, 0, 0},
41365 { "ITEMGETSHOWNNAME", 1, 0, 0, 0},
41366 { "HEROMOVEXY", 0, 0, 0, 0},
41367 { "HEROCANMOVEXY", 0, 0, 0, 0},
41368 { "HEROLIFTRELEASE", 0, 0, 0, 0},
41369 { "HEROLIFTGRAB", 0, 0, 0, 0},
41370 { "LOADPORTAL", 0, 0, 0, 0},
41371 { "CREATEPORTAL", 0, 0, 0, 0},
41372 { "LOADSAVPORTAL", 0, 0, 0, 0},
41373 { "CREATESAVPORTAL", 0, 0, 0, 0},
41374 { "CREATEPALDATA", 0, 0, 0, 0 },
41375 { "CREATEPALDATACLR", 1, 0, 0, 0 },
41376 { "MIXCLR", 0, 0, 0, 0 },
41377 { "CREATERGBHEX", 1, 0, 0, 0 },
41378 { "CREATERGB", 0, 0, 0, 0 },
41379 { "PALDATALOADLEVEL", 1, 0, 0, 0 },
41380 { "PALDATALOADSPRITE", 1, 0, 0, 0 },
41381 { "PALDATALOADMAIN", 0, 0, 0, 0 },
41382 { "PALDATALOADCYCLE", 1, 0, 0, 0 },
41383 { "PALDATALOADBITMAP", 1, 0, 0, 0 },
41384 { "PALDATAWRITELEVEL", 1, 0, 0, 0 },
41385 { "PALDATAWRITELEVELCS", 2, 0, 0, 0 },
41386 { "PALDATAWRITESPRITE", 1, 0, 0, 0 },
41387 { "PALDATAWRITESPRITECS", 2, 0, 0, 0 },
41388 { "PALDATAWRITEMAIN", 0, 0, 0, 0 },
41389 { "PALDATAWRITEMAINCS", 1, 0, 0, 0 },
41390 { "PALDATAWRITECYCLE", 1, 0, 0, 0 },
41391 { "PALDATAWRITECYCLECS", 2, 0, 0, 0 },
41392 { "PALDATAVALIDCLR", 1, 0, 0, 0 },
41393 { "PALDATACLEARCLR", 1, 0, 0, 0 },
41394 { "PALDATACLEARCSET", 1, 0, 0, 0 },
41395 { "PALDATAMIX", 0, 0, 0, 0 },
41396 { "PALDATAMIXCS", 0, 0, 0, 0 },
41397 { "PALDATACOPY", 1, 0, 0, 0 },
41398 { "PALDATACOPYCSET", 0, 0, 0, 0 },
41399 { "PALDATAFREE", 0, 0, 0, 0 },
41400 { "PALDATAOWN", 0, 0, 0, 0 },
41401 { "MAXVARG", 0, 0, 0, 0 },
41402 { "MINVARG", 0, 0, 0, 0 },
41403 { "CHOOSEVARG", 0, 0, 0, 0 },
41404 { "PUSHVARGV", 1, 1, 0, 0 },
41405 { "PUSHVARGR", 1, 0, 0, 0 },
41406 { "PRINTFVARG", 0, 0, 0, 0 },
41407 { "SPRINTFVARG", 0, 0, 0, 0 },
41408 { "TRACELR", 1, 0, 0, 0 },
41409 { "WAITFRAMESR", 1, 0, 0, 0 },
41410 { "RESRVD_OP_Z3_01", 0, 0, 0, 0 },
41411 { "RESRVD_OP_Z3_02", 0, 0, 0, 0 },
41412 { "RESRVD_OP_Z3_03", 0, 0, 0, 0 },
41413 { "RESRVD_OP_Z3_04", 0, 0, 0, 0 },
41414 { "RESRVD_OP_Z3_05", 0, 0, 0, 0 },
41415 { "RESRVD_OP_Z3_06", 0, 0, 0, 0 },
41416 { "RESRVD_OP_Z3_07", 0, 0, 0, 0 },
41417 { "RESRVD_OP_Z3_08", 0, 0, 0, 0 },
41418 { "RESRVD_OP_Z3_09", 0, 0, 0, 0 },
41419 { "RESRVD_OP_Z3_10", 0, 0, 0, 0 },
41420 { "PORTALREMOVE", 0, 0, 0, 0 },
41421 { "SAVEDPORTALREMOVE", 0, 0, 0, 0 },
41422 { "SAVEDPORTALGENERATE", 0, 0, 0, 0 },
41423 { "PORTALUSESPRITE", 1, 0, 0, 0 },
41424 { "HEROMOVEATANGLE", 0, 0, 0, 0 },
41425 { "HEROCANMOVEATANGLE", 0, 0, 0, 0 },
41426 { "HEROMOVE", 0, 0, 0, 0 },
41427 { "HEROCANMOVE", 0, 0, 0, 0 },
41428 { "DRAWLIGHT_CIRCLE", 0, 0, 0, 0 },
41429 { "DRAWLIGHT_SQUARE", 0, 0, 0, 0 },
41430 { "DRAWLIGHT_CONE", 0, 0, 0, 0 },
41431 { "PEEK", 1, 0, 0, 0 },
41432 { "RESRVD_OP_EMILY_10", 0, 0, 0, 0 },
41433 { "RESRVD_OP_EMILY_11", 0, 0, 0, 0 },
41434 { "RESRVD_OP_EMILY_12", 0, 0, 0, 0 },
41435 { "RESRVD_OP_EMILY_13", 0, 0, 0, 0 },
41436 { "RESRVD_OP_EMILY_14", 0, 0, 0, 0 },
41437 { "RESRVD_OP_EMILY_15", 0, 0, 0, 0 },
41438 { "RESRVD_OP_EMILY_16", 0, 0, 0, 0 },
41439 { "RESRVD_OP_EMILY_17", 0, 0, 0, 0 },
41440 { "RESRVD_OP_EMILY_18", 0, 0, 0, 0 },
41441 { "RESRVD_OP_EMILY_19", 0, 0, 0, 0 },
41442 { "RESRVD_OP_EMILY_20", 0, 0, 0, 0 },
41443 { "CONVERTFROMRGB", 0, 0, 0, 0 },
41444 { "CONVERTTORGB", 0, 0, 0, 0 },
41445 { "GETENHMUSICLEN", 1, 0, 0, 0 },
41446 { "SETENHMUSICLOOP", 2, 0, 0, 0 },
41447 { "PLAYSOUNDEX", 0, 0, 0, 0 },
41448 { "GETSFXCOMPLETION", 1, 0, 0, 0 },
41449 { "ENHCROSSFADE", 0, 0, 0, 0 },
41450 { "RESRVD_OP_MOOSH_08", 0, 0, 0, 0 },
41451 { "RESRVD_OP_MOOSH_09", 0, 0, 0, 0 },
41452 { "RESRVD_OP_MOOSH_10", 0, 0, 0, 0 },
41453
41454 { "", 0, 0, 0, 0}
41455 };
41456
41457
41458 script_variable ZASMVars[]=
41459 {
41460 //name id maxcount multiple
41461 { "D", D(0), 8, 0 },
41462 { "A", A(0), 2, 0 },
41463 { "DATA", DATA, 0, 0 },
41464 { "CSET", FCSET, 0, 0 },
41465 { "DELAY", DELAY, 0, 0 },
41466 { "X", FX, 0, 0 },
41467 { "Y", FY, 0, 0 },
41468 { "XD", XD, 0, 0 },
41469 { "YD", YD, 0, 0 },
41470 { "XD2", XD2, 0, 0 },
41471 { "YD2", YD2, 0, 0 },
41472 { "FLAG", FLAG, 0, 0 },
41473 { "WIDTH", WIDTH, 0, 0 },
41474 { "HEIGHT", HEIGHT, 0, 0 },
41475 { "LINK", LINK, 0, 0 },
41476 { "FFFLAGSD", FFFLAGSD, 0, 0 },
41477 { "FFCWIDTH", FFCWIDTH, 0, 0 },
41478 { "FFCHEIGHT", FFCHEIGHT, 0, 0 },
41479 { "FFTWIDTH", FFTWIDTH, 0, 0 },
41480 { "FFTHEIGHT", FFTHEIGHT, 0, 0 },
41481 { "FFLINK", FFLINK, 0, 0 },
41482 // { "COMBOD", COMBOD(0), 176, 3 },
41483 // { "COMBOC", COMBOC(0), 176, 3 },
41484 // { "COMBOF", COMBOF(0), 176, 3 },
41485 { "INPUTSTART", INPUTSTART, 0, 0 },
41486 { "INPUTUP", INPUTUP, 0, 0 },
41487 { "INPUTDOWN", INPUTDOWN, 0, 0 },
41488 { "INPUTLEFT", INPUTLEFT, 0, 0 },
41489 { "INPUTRIGHT", INPUTRIGHT, 0, 0 },
41490 { "INPUTA", INPUTA, 0, 0 },
41491 { "INPUTB", INPUTB, 0, 0 },
41492 { "INPUTL", INPUTL, 0, 0 },
41493 { "INPUTR", INPUTR, 0, 0 },
41494 { "INPUTMOUSEX", INPUTMOUSEX, 0, 0 },
41495 { "INPUTMOUSEY", INPUTMOUSEY, 0, 0 },
41496 { "LINKX", LINKX, 0, 0 },
41497 { "LINKY", LINKY, 0, 0 },
41498 { "LINKZ", LINKZ, 0, 0 },
41499 { "LINKJUMP", LINKJUMP, 0, 0 },
41500 { "LINKDIR", LINKDIR, 0, 0 },
41501 { "LINKHITDIR", LINKHITDIR, 0, 0 },
41502 { "LINKHP", LINKHP, 0, 0 },
41503 { "LINKMP", LINKMP, 0, 0 },
41504 { "LINKMAXHP", LINKMAXHP, 0, 0 },
41505 { "LINKMAXMP", LINKMAXMP, 0, 0 },
41506 { "LINKACTION", LINKACTION, 0, 0 },
41507 { "LINKHELD", LINKHELD, 0, 0 },
41508 { "LINKITEMD", LINKITEMD, 0, 0 },
41509 { "LINKSWORDJINX", LINKSWORDJINX, 0, 0 },
41510 { "LINKITEMJINX", LINKITEMJINX, 0, 0 },
41511 { "LINKDRUNK", LINKDRUNK, 0, 0 },
41512 { "ITEMX", ITEMX, 0, 0 },
41513 { "ITEMY", ITEMY, 0, 0 },
41514 { "ITEMZ", ITEMZ, 0, 0 },
41515 { "ITEMJUMP", ITEMJUMP, 0, 0 },
41516 { "ITEMDRAWTYPE", ITEMDRAWTYPE, 0, 0 },
41517 { "ITEMID", ITEMID, 0, 0 },
41518 { "ITEMTILE", ITEMTILE, 0, 0 },
41519 { "ITEMOTILE", ITEMOTILE, 0, 0 },
41520 { "ITEMCSET", ITEMCSET, 0, 0 },
41521 { "ITEMFLASHCSET", ITEMFLASHCSET, 0, 0 },
41522 { "ITEMFRAMES", ITEMFRAMES, 0, 0 },
41523 { "ITEMFRAME", ITEMFRAME, 0, 0 },
41524 { "ITEMASPEED", ITEMASPEED, 0, 0 },
41525 { "ITEMDELAY", ITEMDELAY, 0, 0 },
41526 { "ITEMFLASH", ITEMFLASH, 0, 0 },
41527 { "ITEMFLIP", ITEMFLIP, 0, 0 },
41528 { "ITEMCOUNT", ITEMCOUNT, 0, 0 },
41529 { "IDATAFAMILY", IDATAFAMILY, 0, 0 },
41530 { "IDATALEVEL", IDATALEVEL, 0, 0 },
41531 { "IDATAKEEP", IDATAKEEP, 0, 0 },
41532 { "IDATAAMOUNT", IDATAAMOUNT, 0, 0 },
41533 { "IDATASETMAX", IDATASETMAX, 0, 0 },
41534 { "IDATAMAX", IDATAMAX, 0, 0 },
41535 { "IDATACOUNTER", IDATACOUNTER, 0, 0 },
41536 { "ITEMEXTEND", ITEMEXTEND, 0, 0 },
41537 { "NPCX", NPCX, 0, 0 },
41538 { "NPCY", NPCY, 0, 0 },
41539 { "NPCZ", NPCZ, 0, 0 },
41540 { "NPCJUMP", NPCJUMP, 0, 0 },
41541 { "NPCDIR", NPCDIR, 0, 0 },
41542 { "NPCRATE", NPCRATE, 0, 0 },
41543 { "NPCSTEP", NPCSTEP, 0, 0 },
41544 { "NPCFRAMERATE", NPCFRAMERATE, 0, 0 },
41545 { "NPCHALTRATE", NPCHALTRATE, 0, 0 },
41546 { "NPCDRAWTYPE", NPCDRAWTYPE, 0, 0 },
41547 { "NPCHP", NPCHP, 0, 0 },
41548 { "NPCID", NPCID, 0, 0 },
41549 { "NPCDP", NPCDP, 0, 0 },
41550 { "NPCWDP", NPCWDP, 0, 0 },
41551 { "NPCOTILE", NPCOTILE, 0, 0 },
41552 { "NPCENEMY", NPCENEMY, 0, 0 },
41553 { "NPCWEAPON", NPCWEAPON, 0, 0 },
41554 { "NPCITEMSET", NPCITEMSET, 0, 0 },
41555 { "NPCCSET", NPCCSET, 0, 0 },
41556 { "NPCBOSSPAL", NPCBOSSPAL, 0, 0 },
41557 { "NPCBGSFX", NPCBGSFX, 0, 0 },
41558 { "NPCCOUNT", NPCCOUNT, 0, 0 },
41559 { "GD", GD(0), 1024, 0 },
41560 { "SDD", SDD, 0, 0 },
41561 { "GDD", GDD, 0, 0 },
41562 { "SDDD", SDDD, 0, 0 },
41563 { "SCRDOORD", SCRDOORD, 0, 0 },
41564 { "GAMEDEATHS", GAMEDEATHS, 0, 0 },
41565 { "GAMECHEAT", GAMECHEAT, 0, 0 },
41566 { "GAMETIME", GAMETIME, 0, 0 },
41567 { "GAMEHASPLAYED", GAMEHASPLAYED, 0, 0 },
41568 { "GAMETIMEVALID", GAMETIMEVALID, 0, 0 },
41569 { "GAMEGUYCOUNT", GAMEGUYCOUNT, 0, 0 },
41570 { "GAMECONTSCR", GAMECONTSCR, 0, 0 },
41571 { "GAMECONTDMAP", GAMECONTDMAP, 0, 0 },
41572 { "GAMECOUNTERD", GAMECOUNTERD, 0, 0 },
41573 { "GAMEMCOUNTERD", GAMEMCOUNTERD, 0, 0 },
41574 { "GAMEDCOUNTERD", GAMEDCOUNTERD, 0, 0 },
41575 { "GAMEGENERICD", GAMEGENERICD, 0, 0 },
41576 { "GAMEMISC", GAMEMISC, 0, 0 },
41577 { "GAMEITEMSD", GAMEITEMSD, 0, 0 },
41578 { "GAMELITEMSD", GAMELITEMSD, 0, 0 },
41579 { "GAMELKEYSD", GAMELKEYSD, 0, 0 },
41580 { "SCREENSTATED", SCREENSTATED, 0, 0 },
41581 { "SCREENSTATEDD", SCREENSTATEDD, 0, 0 },
41582 { "GAMEGUYCOUNTD", GAMEGUYCOUNTD, 0, 0 },
41583 { "CURMAP", CURMAP, 0, 0 },
41584 { "CURSCR", CURSCR, 0, 0 },
41585 { "CURDSCR", CURDSCR, 0, 0 },
41586 { "CURDMAP", CURDMAP, 0, 0 },
41587 { "COMBODD", COMBODD, 0, 0 },
41588 { "COMBOCD", COMBOCD, 0, 0 },
41589 { "COMBOFD", COMBOFD, 0, 0 },
41590 { "COMBOTD", COMBOTD, 0, 0 },
41591 { "COMBOID", COMBOID, 0, 0 },
41592 { "COMBOSD", COMBOSD, 0, 0 },
41593 { "REFITEMCLASS", REFITEMCLASS, 0, 0 },
41594 { "REFITEM", REFITEM, 0, 0 },
41595 { "REFFFC", REFFFC, 0, 0 },
41596 { "REFLWPN", REFLWPN, 0, 0 },
41597 { "REFEWPN", REFEWPN, 0, 0 },
41598 { "REFLWPNCLASS", REFLWPNCLASS, 0, 0 },
41599 { "REFEWPNCLASS", REFEWPNCLASS, 0, 0 },
41600 { "REFNPC", REFNPC, 0, 0 },
41601 { "REFNPCCLASS", REFNPCCLASS, 0, 0 },
41602 { "LWPNX", LWPNX, 0, 0 },
41603 { "LWPNY", LWPNY, 0, 0 },
41604 { "LWPNZ", LWPNZ, 0, 0 },
41605 { "LWPNJUMP", LWPNJUMP, 0, 0 },
41606 { "LWPNDIR", LWPNDIR, 0, 0 },
41607 { "LWPNSTEP", LWPNSTEP, 0, 0 },
41608 { "LWPNANGULAR", LWPNANGULAR, 0, 0 },
41609 { "LWPNANGLE", LWPNANGLE, 0, 0 },
41610 { "LWPNDRAWTYPE", LWPNDRAWTYPE, 0, 0 },
41611 { "LWPNPOWER", LWPNPOWER, 0, 0 },
41612 { "LWPNDEAD", LWPNDEAD, 0, 0 },
41613 { "LWPNID", LWPNID, 0, 0 },
41614 { "LWPNTILE", LWPNTILE, 0, 0 },
41615 { "LWPNCSET", LWPNCSET, 0, 0 },
41616 { "LWPNFLASHCSET", LWPNFLASHCSET, 0, 0 },
41617 { "LWPNFRAMES", LWPNFRAMES, 0, 0 },
41618 { "LWPNFRAME", LWPNFRAME, 0, 0 },
41619 { "LWPNASPEED", LWPNASPEED, 0, 0 },
41620 { "LWPNFLASH", LWPNFLASH, 0, 0 },
41621 { "LWPNFLIP", LWPNFLIP, 0, 0 },
41622 { "LWPNCOUNT", LWPNCOUNT, 0, 0 },
41623 { "LWPNEXTEND", LWPNEXTEND, 0, 0 },
41624 { "LWPNOTILE", LWPNOTILE, 0, 0 },
41625 { "LWPNOCSET", LWPNOCSET, 0, 0 },
41626 { "EWPNX", EWPNX, 0, 0 },
41627 { "EWPNY", EWPNY, 0, 0 },
41628 { "EWPNZ", EWPNZ, 0, 0 },
41629 { "EWPNJUMP", EWPNJUMP, 0, 0 },
41630 { "EWPNDIR", EWPNDIR, 0, 0 },
41631 { "EWPNSTEP", EWPNSTEP, 0, 0 },
41632 { "EWPNANGULAR", EWPNANGULAR, 0, 0 },
41633 { "EWPNANGLE", EWPNANGLE, 0, 0 },
41634 { "EWPNDRAWTYPE", EWPNDRAWTYPE, 0, 0 },
41635 { "EWPNPOWER", EWPNPOWER, 0, 0 },
41636 { "EWPNDEAD", EWPNDEAD, 0, 0 },
41637 { "EWPNID", EWPNID, 0, 0 },
41638 { "EWPNTILE", EWPNTILE, 0, 0 },
41639 { "EWPNCSET", EWPNCSET, 0, 0 },
41640 { "EWPNFLASHCSET", EWPNFLASHCSET, 0, 0 },
41641 { "EWPNFRAMES", EWPNFRAMES, 0, 0 },
41642 { "EWPNFRAME", EWPNFRAME, 0, 0 },
41643 { "EWPNASPEED", EWPNASPEED, 0, 0 },
41644 { "EWPNFLASH", EWPNFLASH, 0, 0 },
41645 { "EWPNFLIP", EWPNFLIP, 0, 0 },
41646 { "EWPNCOUNT", EWPNCOUNT, 0, 0 },
41647 { "EWPNEXTEND", EWPNEXTEND, 0, 0 },
41648 { "EWPNOTILE", EWPNOTILE, 0, 0 },
41649 { "EWPNOCSET", EWPNOCSET, 0, 0 },
41650 { "NPCEXTEND", NPCEXTEND, 0, 0 },
41651 { "SP", SP, 0, 0 },
41652 { "SP", SP, 0, 0 },
41653 { "WAVY", WAVY, 0, 0 },
41654 { "QUAKE", QUAKE, 0, 0 },
41655 { "IDATAUSESOUND", IDATAUSESOUND, 0, 0 },
41656 { "INPUTMOUSEZ", INPUTMOUSEZ, 0, 0 },
41657 { "INPUTMOUSEB", INPUTMOUSEB, 0, 0 },
41658 { "COMBODDM", COMBODDM, 0, 0 },
41659 { "COMBOCDM", COMBOCDM, 0, 0 },
41660 { "COMBOFDM", COMBOFDM, 0, 0 },
41661 { "COMBOTDM", COMBOTDM, 0, 0 },
41662 { "COMBOIDM", COMBOIDM, 0, 0 },
41663 { "COMBOSDM", COMBOSDM, 0, 0 },
41664 { "SCRIPTRAM", SCRIPTRAM, 0, 0 },
41665 { "GLOBALRAM", GLOBALRAM, 0, 0 },
41666 { "SCRIPTRAMD", SCRIPTRAMD, 0, 0 },
41667 { "GLOBALRAMD", GLOBALRAMD, 0, 0 },
41668 { "LWPNHXOFS", LWPNHXOFS, 0, 0 },
41669 { "LWPNHYOFS", LWPNHYOFS, 0, 0 },
41670 { "LWPNXOFS", LWPNXOFS, 0, 0 },
41671 { "LWPNYOFS", LWPNYOFS, 0, 0 },
41672 { "LWPNZOFS", LWPNZOFS, 0, 0 },
41673 { "LWPNHXSZ", LWPNHXSZ, 0, 0 },
41674 { "LWPNHYSZ", LWPNHYSZ, 0, 0 },
41675 { "LWPNHZSZ", LWPNHZSZ, 0, 0 },
41676 { "EWPNHXOFS", EWPNHXOFS, 0, 0 },
41677 { "EWPNHYOFS", EWPNHYOFS, 0, 0 },
41678 { "EWPNXOFS", EWPNXOFS, 0, 0 },
41679 { "EWPNYOFS", EWPNYOFS, 0, 0 },
41680 { "EWPNZOFS", EWPNZOFS, 0, 0 },
41681 { "EWPNHXSZ", EWPNHXSZ, 0, 0 },
41682 { "EWPNHYSZ", EWPNHYSZ, 0, 0 },
41683 { "EWPNHZSZ", EWPNHZSZ, 0, 0 },
41684 { "NPCHXOFS", NPCHXOFS, 0, 0 },
41685 { "NPCHYOFS", NPCHYOFS, 0, 0 },
41686 { "NPCXOFS", NPCXOFS, 0, 0 },
41687 { "NPCYOFS", NPCYOFS, 0, 0 },
41688 { "NPCZOFS", NPCZOFS, 0, 0 },
41689 { "NPCHXSZ", NPCHXSZ, 0, 0 },
41690 { "NPCHYSZ", NPCHYSZ, 0, 0 },
41691 { "NPCHZSZ", NPCHZSZ, 0, 0 },
41692 { "ITEMHXOFS", ITEMHXOFS, 0, 0 },
41693 { "ITEMHYOFS", ITEMHYOFS, 0, 0 },
41694 { "ITEMXOFS", ITEMXOFS, 0, 0 },
41695 { "ITEMYOFS", ITEMYOFS, 0, 0 },
41696 { "ITEMZOFS", ITEMZOFS, 0, 0 },
41697 { "ITEMHXSZ", ITEMHXSZ, 0, 0 },
41698 { "ITEMHYSZ", ITEMHYSZ, 0, 0 },
41699 { "ITEMHZSZ", ITEMHZSZ, 0, 0 },
41700 { "LWPNTXSZ", LWPNTXSZ, 0, 0 },
41701 { "LWPNTYSZ", LWPNTYSZ, 0, 0 },
41702 { "EWPNTXSZ", EWPNTXSZ, 0, 0 },
41703 { "EWPNTYSZ", EWPNTYSZ, 0, 0 },
41704 { "NPCTXSZ", NPCTXSZ, 0, 0 },
41705 { "NPCTYSZ", NPCTYSZ, 0, 0 },
41706 { "ITEMTXSZ", ITEMTXSZ, 0, 0 },
41707 { "ITEMTYSZ", ITEMTYSZ, 0, 0 },
41708 { "LINKHXOFS", LINKHXOFS, 0, 0 },
41709 { "LINKHYOFS", LINKHYOFS, 0, 0 },
41710 { "LINKXOFS", LINKXOFS, 0, 0 },
41711 { "LINKYOFS", LINKYOFS, 0, 0 },
41712 { "LINKZOFS", LINKZOFS, 0, 0 },
41713 { "LINKHXSZ", LINKHXSZ, 0, 0 },
41714 { "LINKHYSZ", LINKHYSZ, 0, 0 },
41715 { "LINKHZSZ", LINKHZSZ, 0, 0 },
41716 { "LINKTXSZ", LINKTXSZ, 0, 0 },
41717 { "LINKTYSZ", LINKTYSZ, 0, 0 },
41718 { "NPCTILE", NPCTILE, 0, 0 },
41719 { "LWPNBEHIND", LWPNBEHIND, 0, 0 },
41720 { "EWPNBEHIND", EWPNBEHIND, 0, 0 },
41721 { "SDDDD", SDDDD, 0, 0 },
41722 { "CURLEVEL", CURLEVEL, 0, 0 },
41723 { "ITEMPICKUP", ITEMPICKUP, 0, 0 },
41724 { "INPUTMAP", INPUTMAP, 0, 0 },
41725 { "LIT", LIT, 0, 0 },
41726 { "INPUTEX1", INPUTEX1, 0, 0 },
41727 { "INPUTEX2", INPUTEX2, 0, 0 },
41728 { "INPUTEX3", INPUTEX3, 0, 0 },
41729 { "INPUTEX4", INPUTEX4, 0, 0 },
41730 { "INPUTPRESSSTART", INPUTPRESSSTART, 0, 0 },
41731 { "INPUTPRESSUP", INPUTPRESSUP, 0, 0 },
41732 { "INPUTPRESSDOWN", INPUTPRESSDOWN, 0, 0 },
41733 { "INPUTPRESSLEFT", INPUTPRESSLEFT, 0, 0 },
41734 { "INPUTPRESSRIGHT", INPUTPRESSRIGHT, 0, 0 },
41735 { "INPUTPRESSA", INPUTPRESSA, 0, 0 },
41736 { "INPUTPRESSB", INPUTPRESSB, 0, 0 },
41737 { "INPUTPRESSL", INPUTPRESSL, 0, 0 },
41738 { "INPUTPRESSR", INPUTPRESSR, 0, 0 },
41739 { "INPUTPRESSEX1", INPUTPRESSEX1, 0, 0 },
41740 { "INPUTPRESSEX2", INPUTPRESSEX2, 0, 0 },
41741 { "INPUTPRESSEX3", INPUTPRESSEX3, 0, 0 },
41742 { "INPUTPRESSEX4", INPUTPRESSEX4, 0, 0 },
41743 { "LWPNMISCD", LWPNMISCD, 0, 0 },
41744 { "EWPNMISCD", EWPNMISCD, 0, 0 },
41745 { "NPCMISCD", NPCMISCD, 0, 0 },
41746 { "ITEMMISCD", ITEMMISCD, 0, 0 },
41747 { "FFMISCD", FFMISCD, 0, 0 },
41748 { "GETMIDI", GETMIDI, 0, 0 },
41749 { "NPCHOMING", NPCHOMING, 0, 0 },
41750 { "NPCDD", NPCDD, 0, 0 },
41751 { "LINKEQUIP", LINKEQUIP, 0, 0 },
41752 { "INPUTAXISUP", INPUTAXISUP, 0, 0 },
41753 { "INPUTAXISDOWN", INPUTAXISDOWN, 0, 0 },
41754 { "INPUTAXISLEFT", INPUTAXISLEFT, 0, 0 },
41755 { "INPUTAXISRIGHT", INPUTAXISRIGHT, 0, 0 },
41756 { "PRESSAXISUP", INPUTPRESSAXISUP, 0, 0 },
41757 { "PRESSAXISDOWN", INPUTPRESSAXISDOWN, 0, 0 },
41758 { "PRESSAXISLEFT", INPUTPRESSAXISLEFT, 0, 0 },
41759 { "PRESSAXISRIGHT", INPUTPRESSAXISRIGHT, 0, 0 },
41760 { "NPCTYPE", NPCTYPE, 0, 0 },
41761 { "FFSCRIPT", FFSCRIPT, 0, 0 },
41762 { "SCREENFLAGSD", SCREENFLAGSD, 0, 0 },
41763 { "LINKINVIS", LINKINVIS, 0, 0 },
41764 { "LINKINVINC", LINKINVINC, 0, 0 },
41765 { "SCREENEFLAGSD", SCREENEFLAGSD, 0, 0 },
41766 { "NPCMFLAGS", NPCMFLAGS, 0, 0 },
41767 { "FFINITDD", FFINITDD, 0, 0 },
41768 { "LINKMISCD", LINKMISCD, 0, 0 },
41769 { "DMAPFLAGSD", DMAPFLAGSD, 0, 0 },
41770 { "LWPNCOLLDET", LWPNCOLLDET, 0, 0 },
41771 { "EWPNCOLLDET", EWPNCOLLDET, 0, 0 },
41772 { "NPCCOLLDET", NPCCOLLDET, 0, 0 },
41773 { "LINKLADDERX", LINKLADDERX, 0, 0 },
41774 { "LINKLADDERY", LINKLADDERY, 0, 0 },
41775 { "NPCSTUN", NPCSTUN, 0, 0 },
41776 { "NPCDEFENSED", NPCDEFENSED, 0, 0 },
41777 { "IDATAPOWER", IDATAPOWER, 0, 0 },
41778 { "DMAPLEVELD", DMAPLEVELD, 0, 0 },
41779 { "DMAPCOMPASSD", DMAPCOMPASSD, 0, 0 },
41780 { "DMAPCONTINUED", DMAPCONTINUED, 0, 0 },
41781 { "DMAPMIDID", DMAPMIDID, 0, 0 },
41782 { "IDATAINITDD", IDATAINITDD, 0, 0 },
41783 { "ROOMTYPE", ROOMTYPE, 0, 0 },
41784 { "ROOMDATA", ROOMDATA, 0, 0 },
41785 { "LINKTILE", LINKTILE, 0, 0 },
41786 { "LINKFLIP", LINKFLIP, 0, 0 },
41787 { "INPUTPRESSMAP", INPUTPRESSMAP, 0, 0 },
41788 { "NPCHUNGER", NPCHUNGER, 0, 0 },
41789 { "GAMESTANDALONE", GAMESTANDALONE, 0, 0 },
41790 { "GAMEENTRSCR", GAMEENTRSCR, 0, 0 },
41791 { "GAMEENTRDMAP", GAMEENTRDMAP, 0, 0 },
41792 { "GAMECLICKFREEZE", GAMECLICKFREEZE, 0, 0 },
41793 { "PUSHBLOCKX", PUSHBLOCKX, 0, 0 },
41794 { "PUSHBLOCKY", PUSHBLOCKY, 0, 0 },
41795 { "PUSHBLOCKCOMBO", PUSHBLOCKCOMBO, 0, 0 },
41796 { "PUSHBLOCKCSET", PUSHBLOCKCSET, 0, 0 },
41797 { "UNDERCOMBO", UNDERCOMBO, 0, 0 },
41798 { "UNDERCSET", UNDERCSET, 0, 0 },
41799 { "DMAPOFFSET", DMAPOFFSET, 0, 0 },
41800 { "DMAPMAP", DMAPMAP, 0, 0 },
41801 { "__RESERVED_FOR_GAMETHROTTLE", __RESERVED_FOR_GAMETHROTTLE, 0, 0 },
41802 { "REFMAPDATA", REFMAPDATA, 0, 0 },
41803 { "REFSCREENDATA", REFSCREENDATA, 0, 0 },
41804 { "REFCOMBODATA", REFCOMBODATA, 0, 0 },
41805 { "REFSPRITEDATA", REFSPRITEDATA, 0, 0 },
41806 { "REFBITMAP", REFBITMAP, 0, 0 },
41807 { "REFDMAPDATA", REFDMAPDATA, 0, 0 },
41808 { "REFSHOPDATA", REFSHOPDATA, 0, 0 },
41809 { "REFMSGDATA", REFMSGDATA, 0, 0 },
41810 { "REFUNTYPED", REFUNTYPED, 0, 0 },
41811 { "REFDROPS", REFDROPS, 0, 0 },
41812 { "REFPONDS", REFPONDS, 0, 0 },
41813 { "REFWARPRINGS", REFWARPRINGS, 0, 0 },
41814 { "REFDOORS", REFDOORS, 0, 0 },
41815 { "REFUICOLOURS", REFUICOLOURS, 0, 0 },
41816 { "REFRGB", REFRGB, 0, 0 },
41817 { "REFPALETTE", REFPALETTE, 0, 0 },
41818 { "REFTUNES", REFTUNES, 0, 0 },
41819 { "REFPALCYCLE", REFPALCYCLE, 0, 0 },
41820 { "REFGAMEDATA", REFGAMEDATA, 0, 0 },
41821 { "REFCHEATS", REFCHEATS, 0, 0 },
41822 { "IDATAMAGICTIMER", IDATAMAGICTIMER, 0, 0 },
41823 { "IDATALTM", IDATALTM, 0, 0 },
41824 { "IDATASCRIPT", IDATASCRIPT, 0, 0 },
41825 { "IDATAPSCRIPT", IDATAPSCRIPT, 0, 0 },
41826 { "IDATAMAGCOST", IDATAMAGCOST, 0, 0 },
41827 { "IDATAMINHEARTS", IDATAMINHEARTS, 0, 0 },
41828 { "IDATATILE", IDATATILE, 0, 0 },
41829 { "IDATAMISC", IDATAMISC, 0, 0 },
41830 { "IDATACSET", IDATACSET, 0, 0 },
41831 { "IDATAFRAMES", IDATAFRAMES, 0, 0 },
41832 { "IDATAASPEED", IDATAASPEED, 0, 0 },
41833 { "IDATADELAY", IDATADELAY, 0, 0 },
41834 { "IDATACOMBINE", IDATACOMBINE, 0, 0 },
41835 { "IDATADOWNGRADE", IDATADOWNGRADE, 0, 0 },
41836 { "IDATAPSTRING", IDATAPSTRING, 0, 0 },
41837 { "IDATAPFLAGS", IDATAPFLAGS, 0, 0 },
41838 { "IDATAKEEPOLD", IDATAKEEPOLD, 0, 0 },
41839 { "IDATARUPEECOST", IDATARUPEECOST, 0, 0 },
41840 { "IDATAEDIBLE", IDATAEDIBLE, 0, 0 },
41841 { "IDATAFLAGUNUSED", IDATAFLAGUNUSED, 0, 0 },
41842 { "IDATAGAINLOWER", IDATAGAINLOWER, 0, 0 },
41843 { "RESVD0024", RESVD024, 0, 0 },
41844 { "RESVD0025", RESVD025, 0, 0 },
41845 { "RESVD0026", RESVD026, 0, 0 },
41846 { "IDATAID", IDATAID, 0, 0 },
41847 { "__RESERVED_FOR_LINKEXTEND", __RESERVED_FOR_LINKEXTEND, 0, 0 },
41848 { "NPCSCRDEFENSED", NPCSCRDEFENSED, 0, 0 },
41849 { "__RESERVED_FOR_SETLINKTILE", __RESERVED_FOR_SETLINKTILE, 0, 0 },
41850 { "__RESERVED_FOR_SETLINKEXTEND", __RESERVED_FOR_SETLINKEXTEND, 0, 0 },
41851 { "__RESERVED_FOR_SIDEWARPSFX", __RESERVED_FOR_SIDEWARPSFX, 0, 0 },
41852 { "__RESERVED_FOR_PITWARPSFX", __RESERVED_FOR_PITWARPSFX, 0, 0 },
41853 { "__RESERVED_FOR_SIDEWARPVISUAL", __RESERVED_FOR_SIDEWARPVISUAL, 0, 0 },
41854 { "__RESERVED_FOR_PITWARPVISUAL", __RESERVED_FOR_PITWARPVISUAL, 0, 0 },
41855 { "GAMESETA", GAMESETA, 0, 0 },
41856 { "GAMESETB", GAMESETB, 0, 0 },
41857 { "SETITEMSLOT", SETITEMSLOT, 0, 0 },
41858 { "LINKITEMB", LINKITEMB, 0, 0 },
41859 { "LINKITEMA", LINKITEMA, 0, 0 },
41860 { "__RESERVED_FOR_LINKWALKTILE", __RESERVED_FOR_LINKWALKTILE, 0, 0 }, //Walk sprite
41861 { "__RESERVED_FOR_LINKFLOATTILE", __RESERVED_FOR_LINKFLOATTILE, 0, 0 }, //float sprite
41862 { "__RESERVED_FOR_LINKSWIMTILE", __RESERVED_FOR_LINKSWIMTILE, 0, 0 }, //swim sprite
41863 { "__RESERVED_FOR_LINKDIVETILE", __RESERVED_FOR_LINKDIVETILE, 0, 0 }, //dive sprite
41864 { "__RESERVED_FOR_LINKSLASHTILE", __RESERVED_FOR_LINKSLASHTILE, 0, 0 }, //slash sprite
41865 { "__RESERVED_FOR_LINKJUMPTILE", __RESERVED_FOR_LINKJUMPTILE, 0, 0 }, //jump sprite
41866 { "__RESERVED_FOR_LINKCHARGETILE", __RESERVED_FOR_LINKCHARGETILE, 0, 0 }, //charge sprite
41867 { "__RESERVED_FOR_LINKSTABTILE", __RESERVED_FOR_LINKSTABTILE, 0, 0 }, //stab sprite
41868 { "__RESERVED_FOR_LINKCASTTILE", __RESERVED_FOR_LINKCASTTILE, 0, 0 }, //casting sprite
41869 { "__RESERVED_FOR_LINKHOLD1LTILE", __RESERVED_FOR_LINKHOLD1LTILE, 0, 0 }, //hold1land sprite
41870 { "__RESERVED_FOR_LINKHOLD2LTILE", __RESERVED_FOR_LINKHOLD2LTILE, 0, 0 }, //hold2land sprite
41871 { "__RESERVED_FOR_LINKHOLD1WTILE", __RESERVED_FOR_LINKHOLD1WTILE, 0, 0 }, //hold1water sprite
41872 { "__RESERVED_FOR_LINKHOLD2WTILE", __RESERVED_FOR_LINKHOLD2WTILE, 0, 0 }, //hold2water sprite
41873 { "__RESERVED_FOR_LINKPOUNDTILE", __RESERVED_FOR_LINKPOUNDTILE, 0, 0 }, //hammer pound sprite
41874 { "__RESERVED_FOR_LINKSWIMSPD", __RESERVED_FOR_LINKSWIMSPD, 0, 0 },
41875 { "__RESERVED_FOR_LINKWALKANMSPD", __RESERVED_FOR_LINKWALKANMSPD, 0, 0 },
41876 { "__RESERVED_FOR_LINKANIMTYPE", __RESERVED_FOR_LINKANIMTYPE, 0, 0 },
41877 { "LINKINVFRAME", LINKINVFRAME, 0, 0 },
41878 { "LINKCANFLICKER", LINKCANFLICKER, 0, 0 },
41879 { "LINKHURTSFX", LINKHURTSFX, 0, 0 },
41880 { "NOACTIVESUBSC", NOACTIVESUBSC, 0, 0 },
41881 { "LWPNRANGE", LWPNRANGE, 0, 0 },
41882 { "ZELDAVERSION", ZELDAVERSION, 0, 0 },
41883 { "ZELDABUILD", ZELDABUILD, 0, 0 },
41884 { "ZELDABETA", ZELDABETA, 0, 0 },
41885 { "NPCINVINC", NPCINVINC, 0, 0 },
41886 { "NPCSUPERMAN", NPCSUPERMAN, 0, 0 },
41887 { "NPCHASITEM", NPCHASITEM, 0, 0 },
41888 { "NPCRINGLEAD", NPCRINGLEAD, 0, 0 },
41889 { "IDATAFRAME", IDATAFRAME, 0, 0 },
41890 { "ITEMACLK", ITEMACLK, 0, 0 },
41891 { "FFCID", FFCID, 0, 0 },
41892 { "IDATAATTRIB", IDATAATTRIB, 0, 0 },
41893 { "IDATASPRITE", IDATASPRITE, 0, 0 },
41894 { "IDATAFLAGS", IDATAFLAGS, 0, 0 },
41895 { "DMAPLEVELPAL", DMAPLEVELPAL, 0, 0 },
41896 { "__RESERVED_FOR_ITEMPTR", __RESERVED_FOR_ITEMPTR, 0, 0 },
41897 { "__RESERVED_FOR_NPCPTR", __RESERVED_FOR_NPCPTR, 0, 0 },
41898 { "__RESERVED_FOR_LWPNPTR", __RESERVED_FOR_LWPNPTR, 0, 0 },
41899 { "__RESERVED_FOR_EWPNPTR", __RESERVED_FOR_EWPNPTR, 0, 0 },
41900 { "SETSCREENDOOR", SETSCREENDOOR, 0, 0 },
41901 { "SETSCREENENEMY", SETSCREENENEMY, 0, 0 },
41902 { "GAMEMAXMAPS", GAMEMAXMAPS, 0, 0 },
41903 { "CREATELWPNDX", CREATELWPNDX, 0, 0 },
41904 { "__RESERVED_FOR_SCREENFLAG", __RESERVED_FOR_SCREENFLAG, 0, 0 },
41905 { "BUTTONPRESS", BUTTONPRESS, 0, 0 },
41906 { "BUTTONINPUT", BUTTONINPUT, 0, 0 },
41907 { "BUTTONHELD", BUTTONHELD, 0, 0 },
41908 { "RAWKEY", RAWKEY, 0, 0 },
41909 { "READKEY", READKEY, 0, 0 },
41910 { "JOYPADPRESS", JOYPADPRESS, 0, 0 },
41911 { "DISABLEDITEM", DISABLEDITEM, 0, 0 },
41912 { "LINKDIAG", LINKDIAG, 0, 0 },
41913 { "LINKBIGHITBOX", LINKBIGHITBOX, 0, 0 },
41914 { "LINKEATEN", LINKEATEN, 0, 0 },
41915 { "__RESERVED_FOR_LINKRETSQUARE", __RESERVED_FOR_LINKRETSQUARE, 0, 0 },
41916 { "__RESERVED_FOR_LINKWARPSOUND", __RESERVED_FOR_LINKWARPSOUND, 0, 0 },
41917 { "__RESERVED_FOR_PLAYPITWARPSFX", __RESERVED_FOR_PLAYPITWARPSFX, 0, 0 },
41918 { "__RESERVED_FOR_WARPEFFECT", __RESERVED_FOR_WARPEFFECT, 0, 0 },
41919 { "__RESERVED_FOR_PLAYWARPSOUND", __RESERVED_FOR_PLAYWARPSOUND, 0, 0 },
41920 { "LINKUSINGITEM", LINKUSINGITEM, 0, 0 },
41921 { "LINKUSINGITEMA", LINKUSINGITEMA, 0, 0 },
41922 { "LINKUSINGITEMB", LINKUSINGITEMB, 0, 0 },
41923 // { "DMAPLEVELPAL", DMAPLEVELPAL, 0, 0 },
41924 // { "LINKZHEIGHT", LINKZHEIGHT, 0, 0 },
41925 // { "ITEMINDEX", ITEMINDEX, 0, 0 },
41926 // { "LWPNINDEX", LWPNINDEX, 0, 0 },
41927 // { "EWPNINDEX", EWPNINDEX, 0, 0 },
41928 // { "NPCINDEX", NPCINDEX, 0, 0 },
41929 //TABLE END
41930 { "IDATAUSEWPN", IDATAUSEWPN, 0, 0 }, //UseWeapon
41931 { "IDATAUSEDEF", IDATAUSEDEF, 0, 0 }, //UseDefense
41932 { "IDATAWRANGE", IDATAWRANGE, 0, 0 }, //Range
41933 { "IDATAUSEMVT", IDATAUSEMVT, 0, 0 }, //Movement[]
41934 { "IDATADURATION", IDATADURATION, 0, 0 }, //Duration
41935
41936 { "IDATADUPLICATES", IDATADUPLICATES, 0, 0 }, //Duplicates
41937 { "IDATADRAWLAYER", IDATADRAWLAYER, 0, 0 }, //DrawLayer
41938 { "IDATACOLLECTFLAGS", IDATACOLLECTFLAGS, 0, 0 }, //CollectFlags
41939 { "IDATAWEAPONSCRIPT", IDATAWEAPONSCRIPT, 0, 0 }, //WeaponScript
41940 { "IDATAMISCD", IDATAMISCD, 0, 0 }, //WeaponMisc[32]
41941 { "IDATAWEAPHXOFS", IDATAWEAPHXOFS, 0, 0 }, //WeaponHitXOffset
41942 { "IDATAWEAPHYOFS", IDATAWEAPHYOFS, 0, 0 }, //WeaponHitYOffset
41943 { "IDATAWEAPHXSZ", IDATAWEAPHYSZ, 0, 0 }, //WeaponHitWidth
41944 { "IDATAWEAPHYSZ", IDATAWEAPHYSZ, 0, 0 }, //WeaponHitHeight
41945 { "IDATAWEAPHZSZ", IDATAWEAPHZSZ, 0, 0 }, //WeaponHitZHeight
41946 { "IDATAWEAPXOFS", IDATAWEAPXOFS, 0, 0 }, //WeaponDrawXOffset
41947 { "IDATAWEAPYOFS", IDATAWEAPYOFS, 0, 0 }, //WeaponDrawYOffset
41948 { "IDATAWEAPZOFS", IDATAWEAPZOFS, 0, 0 }, //WeaponDrawZOffset
41949 { "IDATAWPNINITD", IDATAWPNINITD, 0, 0 }, //WeaponD[8]
41950
41951 { "NPCWEAPSPRITE", NPCWEAPSPRITE, 0, 0 }, //WeaponSprite
41952
41953 { "DEBUGREFFFC", DEBUGREFFFC, 0, 0 }, //REFFFC
41954 { "DEBUGREFITEM", DEBUGREFITEM, 0, 0 }, //REFITEM
41955 { "DEBUGREFNPC", DEBUGREFNPC, 0, 0 }, //REFNPC
41956 { "DEBUGREFITEMDATA", DEBUGREFITEMDATA, 0, 0 }, //REFITEMCLASS
41957 { "DEBUGREFLWEAPON", DEBUGREFLWEAPON, 0, 0 }, //REFLWPN
41958 { "DEBUGREFEWEAPON", DEBUGREFEWEAPON, 0, 0 }, //REFEWPN
41959 { "DEBUGSP", DEBUGSP, 0, 0 }, //SP
41960 { "DEBUGGDR", DEBUGGDR, 0, 0 }, //GDR[256]
41961 { "SCREENWIDTH", SCREENWIDTH, 0, 0 },
41962 { "SCREENHEIGHT", SCREENHEIGHT, 0, 0 },
41963 { "SCREENVIEWX", SCREENVIEWX, 0, 0 },
41964 { "SCREENVIEWY", SCREENVIEWY, 0, 0 },
41965 { "SCREENGUY", SCREENGUY, 0, 0 },
41966 { "SCREENSTRING", SCREENSTRING, 0, 0 },
41967 { "SCREENROOM", SCREENROOM, 0, 0 },
41968 { "SCREENENTX", SCREENENTX, 0, 0 },
41969 { "SCREENENTY", SCREENENTY, 0, 0 },
41970 { "SCREENITEM", SCREENITEM, 0, 0 },
41971 { "SCREENUNDCMB", SCREENUNDCMB, 0, 0 },
41972 { "SCREENUNDCST", SCREENUNDCST, 0, 0 },
41973 { "SCREENCATCH", SCREENCATCH, 0, 0 },
41974 { "SETSCREENLAYOP", SETSCREENLAYOP, 0, 0 },
41975 { "SETSCREENSECCMB", SETSCREENSECCMB, 0, 0 },
41976 { "SETSCREENSECCST", SETSCREENSECCST, 0, 0 },
41977 { "SETSCREENSECFLG", SETSCREENSECFLG, 0, 0 },
41978 { "SETSCREENLAYMAP", SETSCREENLAYMAP, 0, 0 },
41979 { "SETSCREENLAYSCR", SETSCREENLAYSCR, 0, 0 },
41980 { "SETSCREENPATH", SETSCREENPATH, 0, 0 },
41981 { "SETSCREENWARPRX", SETSCREENWARPRX, 0, 0 },
41982 { "SETSCREENWARPRY", SETSCREENWARPRY, 0, 0 },
41983 {"GAMENUMMESSAGES", GAMENUMMESSAGES, 0, 0 },
41984 {"GAMESUBSCHEIGHT", GAMESUBSCHEIGHT, 0, 0 },
41985 {"GAMEPLAYFIELDOFS", GAMEPLAYFIELDOFS, 0, 0 },
41986 {"PASSSUBOFS", PASSSUBOFS, 0, 0 }, //
41987
41988
41989 //NPCData
41990 {"SETNPCDATASCRIPTDEF", SETNPCDATASCRIPTDEF, 0, 0 },
41991 {"SETNPCDATADEFENSE", SETNPCDATADEFENSE, 0, 0 },
41992 {"SETNPCDATASIZEFLAG", SETNPCDATASIZEFLAG, 0, 0 },
41993 {"SETNPCDATAATTRIBUTE", SETNPCDATAATTRIBUTE, 0, 0 },
41994
41995 {"SCDBLOCKWEAPON", SCDBLOCKWEAPON, 0, 0 },
41996 {"SCDSTRIKEWEAPONS", SCDSTRIKEWEAPONS, 0, 0 },
41997 {"SCDEXPANSION", SCDEXPANSION, 0, 0 },
41998 {"SETGAMEOVERELEMENT", SETGAMEOVERELEMENT, 0, 0 },
41999 {"SETGAMEOVERSTRING", SETGAMEOVERSTRING, 0, 0 },
42000 {"MOUSEARR", MOUSEARR, 0, 0 },
42001
42002 {"IDATAOVERRIDEFLWEAP", IDATAOVERRIDEFLWEAP, 0, 0 },
42003 {"IDATATILEHWEAP", IDATATILEHWEAP, 0, 0 },
42004 {"IDATATILEWWEAP", IDATATILEWWEAP, 0, 0 },
42005 {"IDATAHZSZWEAP", IDATAHZSZWEAP, 0, 0 },
42006 {"IDATAHYSZWEAP", IDATAHYSZWEAP, 0, 0 },
42007 {"IDATAHXSZWEAP", IDATAHXSZWEAP, 0, 0 },
42008 {"IDATADYOFSWEAP", IDATADYOFSWEAP, 0, 0 },
42009 {"IDATADXOFSWEAP", IDATADXOFSWEAP, 0, 0 },
42010 {"IDATAHYOFSWEAP", IDATAHYOFSWEAP, 0, 0 },
42011 {"IDATAHXOFSWEAP", IDATAHXOFSWEAP, 0, 0 },
42012 {"IDATAOVERRIDEFL", IDATAOVERRIDEFL, 0, 0 },
42013 {"IDATAPICKUP", IDATAPICKUP, 0, 0 },
42014 {"IDATATILEH", IDATATILEH, 0, 0 },
42015 {"IDATATILEW", IDATATILEW, 0, 0 },
42016 {"IDATAHZSZ", IDATAHZSZ, 0, 0 },
42017 {"IDATAHYSZ", IDATAHYSZ, 0, 0 },
42018 {"IDATAHXSZ", IDATAHXSZ, 0, 0 },
42019 {"IDATADYOFS", IDATADYOFS, 0, 0 },
42020 {"IDATADXOFS", IDATADXOFS, 0, 0 },
42021 {"IDATAHYOFS", IDATAHYOFS, 0, 0 },
42022 {"IDATAHXOFS", IDATAHXOFS, 0, 0 },
42023 //spritedata sd->
42024 {"SPRITEDATATILE", SPRITEDATATILE, 0, 0 },
42025 {"SPRITEDATAMISC", SPRITEDATAMISC, 0, 0 },
42026 {"SPRITEDATACSETS", SPRITEDATACSETS, 0, 0 },
42027 {"SPRITEDATAFRAMES", SPRITEDATAFRAMES, 0, 0 },
42028 {"SPRITEDATASPEED", SPRITEDATASPEED, 0, 0 },
42029 {"SPRITEDATATYPE", SPRITEDATATYPE, 0, 0 },
42030
42031 //npcdata nd->
42032 {"NPCDATATILE", NPCDATATILE, 0, 0 },
42033 {"NPCDATAHEIGHT", NPCDATAHEIGHT, 0, 0 },
42034 {"NPCDATAFLAGS", NPCDATAFLAGS, 0, 0 },
42035 {"NPCDATAFLAGS2", NPCDATAFLAGS2, 0, 0 },
42036 {"NPCDATAWIDTH", NPCDATAWIDTH, 0, 0 },
42037 {"NPCDATAHITSFX", NPCDATAHITSFX, 0, 0 },
42038 {"NPCDATASTILE", NPCDATASTILE, 0, 0 },
42039 {"NPCDATASWIDTH", NPCDATASWIDTH, 0, 0 },
42040 {"NPCDATASHEIGHT", NPCDATASHEIGHT, 0, 0 },
42041 {"NPCDATAETILE", NPCDATAETILE, 0, 0 },
42042 {"NPCDATAEWIDTH", NPCDATAEWIDTH, 0, 0 },
42043 {"NPCDATAEHEIGHT", NPCDATAEHEIGHT, 0, 0 },
42044 {"NPCDATAHP", NPCDATAHP, 0, 0 },
42045 {"NPCDATAFAMILY", NPCDATAFAMILY, 0, 0 },
42046 {"NPCDATACSET", NPCDATACSET, 0, 0 },
42047 {"NPCDATAANIM", NPCDATAANIM, 0, 0 },
42048 {"NPCDATAEANIM", NPCDATAEANIM, 0, 0 },
42049 {"NPCDATAFRAMERATE", NPCDATAFRAMERATE, 0, 0 },
42050 {"NPCDATAEFRAMERATE", NPCDATAEFRAMERATE, 0, 0 },
42051 {"NPCDATATOUCHDAMAGE", NPCDATATOUCHDAMAGE, 0, 0 },
42052 {"NPCDATAWEAPONDAMAGE", NPCDATAWEAPONDAMAGE, 0, 0 },
42053 {"NPCDATAWEAPON", NPCDATAWEAPON, 0, 0 },
42054 {"NPCDATARANDOM", NPCDATARANDOM, 0, 0 },
42055 {"NPCDATAHALT", NPCDATAHALT, 0, 0 },
42056 {"NPCDATASTEP", NPCDATASTEP, 0, 0 },
42057 {"NPCDATAHOMING", NPCDATAHOMING, 0, 0 },
42058 {"NPCDATAHUNGER", NPCDATAHUNGER, 0, 0 },
42059 {"NPCDATADROPSET", NPCDATADROPSET, 0, 0 },
42060 {"NPCDATABGSFX", NPCDATABGSFX, 0, 0 },
42061 {"NPCDATADEATHSFX", NPCDATADEATHSFX, 0, 0 },
42062 {"NPCDATAXOFS", NPCDATAXOFS, 0, 0 },
42063 {"NPCDATAYOFS", NPCDATAYOFS, 0, 0 },
42064 {"NPCDATAZOFS", NPCDATAZOFS, 0, 0 },
42065 {"NPCDATAHXOFS", NPCDATAHXOFS, 0, 0 },
42066 {"NPCDATAHYOFS", NPCDATAHYOFS, 0, 0 },
42067 {"NPCDATAHITWIDTH", NPCDATAHITWIDTH, 0, 0 },
42068 {"NPCDATAHITHEIGHT", NPCDATAHITHEIGHT, 0, 0 },
42069 {"NPCDATAHITZ", NPCDATAHITZ, 0, 0 },
42070 {"NPCDATATILEWIDTH", NPCDATATILEWIDTH, 0, 0 },
42071 {"NPCDATATILEHEIGHT", NPCDATATILEHEIGHT, 0, 0 },
42072 {"NPCDATAWPNSPRITE", NPCDATAWPNSPRITE, 0, 0 },
42073 {"NPCDATADEFENSE", NPCDATADEFENSE, 0, 0 },
42074 {"NPCDATASIZEFLAG", NPCDATASIZEFLAG, 0, 0 },
42075 {"NPCDATAATTRIBUTE", NPCDATAATTRIBUTE, 0, 0 },
42076
42077 {"NPCDATAFROZENTILE", NPCDATAFROZENTILE, 0, 0 },
42078 {"NPCDATAFROZENCSET", NPCDATAFROZENCSET, 0, 0 },
42079
42080 //mapdata md->
42081 {"MAPDATAVALID", MAPDATAVALID, 0, 0 },
42082 {"MAPDATAGUY", MAPDATAGUY, 0, 0 },
42083 {"MAPDATASTRING", MAPDATASTRING, 0, 0 },
42084 {"MAPDATAROOM", MAPDATAROOM, 0, 0 },
42085 {"MAPDATAITEM", MAPDATAITEM, 0, 0 },
42086 {"MAPDATAHASITEM", MAPDATAHASITEM, 0, 0 },
42087 {"MAPDATATILEWARPTYPE", MAPDATATILEWARPTYPE, 0, 0 },
42088 {"MAPDATATILEWARPOVFLAGS", MAPDATATILEWARPOVFLAGS, 0, 0 },
42089 {"MAPDATADOORCOMBOSET", MAPDATADOORCOMBOSET, 0, 0 },
42090 {"MAPDATAWARPRETX", MAPDATAWARPRETX, 0, 0 },
42091 {"MAPDATAWARPRETY", MAPDATAWARPRETY, 0, 0 },
42092 {"MAPDATAWARPRETURNC", MAPDATAWARPRETURNC, 0, 0 },
42093 {"MAPDATASTAIRX", MAPDATASTAIRX, 0, 0 },
42094 {"MAPDATASTAIRY", MAPDATASTAIRY, 0, 0 },
42095 {"MAPDATACOLOUR", MAPDATACOLOUR, 0, 0 },
42096 {"MAPDATAENEMYFLAGS", MAPDATAENEMYFLAGS, 0, 0 },
42097 {"MAPDATADOOR", MAPDATADOOR, 0, 0 },
42098 {"MAPDATATILEWARPDMAP", MAPDATATILEWARPDMAP, 0, 0 },
42099 {"MAPDATATILEWARPSCREEN", MAPDATATILEWARPSCREEN, 0, 0 },
42100 {"MAPDATAEXITDIR", MAPDATAEXITDIR, 0, 0 },
42101 {"MAPDATAENEMY", MAPDATAENEMY, 0, 0 },
42102 {"MAPDATAPATTERN", MAPDATAPATTERN, 0, 0 },
42103 {"MAPDATASIDEWARPTYPE", MAPDATASIDEWARPTYPE, 0, 0 },
42104 {"MAPDATASIDEWARPOVFLAGS", MAPDATASIDEWARPOVFLAGS, 0, 0 },
42105 {"MAPDATAWARPARRIVALX", MAPDATAWARPARRIVALX, 0, 0 },
42106 {"MAPDATAWARPARRIVALY", MAPDATAWARPARRIVALY, 0, 0 },
42107 {"MAPDATAPATH", MAPDATAPATH, 0, 0 },
42108 {"MAPDATASIDEWARPSC", MAPDATASIDEWARPSC, 0, 0 },
42109 {"MAPDATASIDEWARPDMAP", MAPDATASIDEWARPDMAP, 0, 0 },
42110 {"MAPDATASIDEWARPINDEX", MAPDATASIDEWARPINDEX, 0, 0 },
42111 {"MAPDATAUNDERCOMBO", MAPDATAUNDERCOMBO, 0, 0 },
42112 {"MAPDATAUNDERCSET", MAPDATAUNDERCSET, 0, 0 },
42113 {"MAPDATACATCHALL", MAPDATACATCHALL, 0, 0 },
42114 {"MAPDATAFLAGS", MAPDATAFLAGS, 0, 0 },
42115 {"MAPDATACSENSITIVE", MAPDATACSENSITIVE, 0, 0 },
42116 {"MAPDATANORESET", MAPDATANORESET, 0, 0 },
42117 {"MAPDATANOCARRY", MAPDATANOCARRY, 0, 0 },
42118 {"MAPDATALAYERMAP", MAPDATALAYERMAP, 0, 0 },
42119 {"MAPDATALAYERSCREEN", MAPDATALAYERSCREEN, 0, 0 },
42120 {"MAPDATALAYEROPACITY", MAPDATALAYEROPACITY, 0, 0 },
42121 {"MAPDATATIMEDWARPTICS", MAPDATATIMEDWARPTICS, 0, 0 },
42122 {"MAPDATANEXTMAP", MAPDATANEXTMAP, 0, 0 },
42123 {"MAPDATANEXTSCREEN", MAPDATANEXTSCREEN, 0, 0 },
42124 {"MAPDATASECRETCOMBO", MAPDATASECRETCOMBO, 0, 0 },
42125 {"MAPDATASECRETCSET", MAPDATASECRETCSET, 0, 0 },
42126 {"MAPDATASECRETFLAG", MAPDATASECRETFLAG, 0, 0 },
42127 {"MAPDATAVIEWX", MAPDATAVIEWX, 0, 0 },
42128 {"MAPDATAVIEWY", MAPDATAVIEWY, 0, 0 },
42129 {"MAPDATASCREENWIDTH", MAPDATASCREENWIDTH, 0, 0 },
42130 {"MAPDATASCREENHEIGHT", MAPDATASCREENHEIGHT, 0, 0 },
42131 {"MAPDATAENTRYX", MAPDATAENTRYX, 0, 0 },
42132 {"MAPDATAENTRYY", MAPDATAENTRYY, 0, 0 },
42133 {"MAPDATANUMFF", MAPDATANUMFF, 0, 0 },
42134 {"MAPDATAFFDATA", MAPDATAFFDATA, 0, 0 },
42135 {"MAPDATAFFCSET", MAPDATAFFCSET, 0, 0 },
42136 {"MAPDATAFFDELAY", MAPDATAFFDELAY, 0, 0 },
42137 {"MAPDATAFFX", MAPDATAFFX, 0, 0 },
42138 {"MAPDATAFFY", MAPDATAFFY, 0, 0 },
42139 {"MAPDATAFFXDELTA", MAPDATAFFXDELTA, 0, 0 },
42140 {"MAPDATAFFYDELTA", MAPDATAFFYDELTA, 0, 0 },
42141 {"MAPDATAFFXDELTA2", MAPDATAFFXDELTA2, 0, 0 },
42142 {"MAPDATAFFYDELTA2", MAPDATAFFYDELTA2, 0, 0 },
42143 {"MAPDATAFFFLAGS", MAPDATAFFFLAGS, 0, 0 },
42144 {"MAPDATAFFWIDTH", MAPDATAFFWIDTH, 0, 0 },
42145 {"MAPDATAFFHEIGHT", MAPDATAFFHEIGHT, 0, 0 },
42146 {"MAPDATAFFLINK", MAPDATAFFLINK, 0, 0 },
42147 {"MAPDATAFFSCRIPT", MAPDATAFFSCRIPT, 0, 0 },
42148 {"MAPDATAINTID", MAPDATAINTID, 0, 0 }, //Needs to be a function [32][10]
42149 {"MAPDATAINITA", MAPDATAINITA, 0, 0 }, //needs to be a function, [32][2]
42150 {"MAPDATAFFINITIALISED", MAPDATAFFINITIALISED, 0, 0 },
42151 {"MAPDATASCRIPTENTRY", MAPDATASCRIPTENTRY, 0, 0 },
42152 {"MAPDATASCRIPTOCCUPANCY", MAPDATASCRIPTOCCUPANCY, 0, 0 },
42153 {"MAPDATASCRIPTEXIT", MAPDATASCRIPTEXIT, 0, 0 },
42154 {"MAPDATAOCEANSFX", MAPDATAOCEANSFX, 0, 0 },
42155 {"MAPDATABOSSSFX", MAPDATABOSSSFX, 0, 0 },
42156 {"MAPDATASECRETSFX", MAPDATASECRETSFX, 0, 0 },
42157 {"MAPDATAHOLDUPSFX", MAPDATAHOLDUPSFX, 0, 0 },
42158 {"MAPDATASCREENMIDI", MAPDATASCREENMIDI, 0, 0 },
42159 {"MAPDATALENSLAYER", MAPDATALENSLAYER, 0, 0 },
42160 {"MAPDATAMISCD", MAPDATAMISCD, 0, 0},
42161
42162 {"MAPDATASCREENSTATED", MAPDATASCREENSTATED, 0, 0},
42163 {"MAPDATASCREENFLAGSD", MAPDATASCREENFLAGSD, 0, 0},
42164 {"MAPDATASCREENEFLAGSD", MAPDATASCREENEFLAGSD, 0, 0},
42165
42166
42167
42168 {"MAPDATACOMBODD", MAPDATACOMBODD, 0, 0},
42169 {"MAPDATACOMBOCD", MAPDATACOMBOCD, 0, 0},
42170 {"MAPDATACOMBOFD", MAPDATACOMBOFD, 0, 0},
42171 {"MAPDATACOMBOTD", MAPDATACOMBOTD, 0, 0},
42172 {"MAPDATACOMBOID", MAPDATACOMBOID, 0, 0},
42173 {"MAPDATACOMBOSD", MAPDATACOMBOSD, 0, 0},
42174
42175 {"SCREENDATAVALID", SCREENDATAVALID, 0, 0 },
42176 {"SCREENDATAGUY", SCREENDATAGUY, 0, 0 },
42177 {"SCREENDATASTRING", SCREENDATASTRING, 0, 0 },
42178 {"SCREENDATAROOM", SCREENDATAROOM, 0, 0 },
42179 {"SCREENDATAITEM", SCREENDATAITEM, 0, 0 },
42180 {"SCREENDATAHASITEM", SCREENDATAHASITEM, 0, 0 },
42181 {"SCREENDATATILEWARPTYPE", SCREENDATATILEWARPTYPE, 0, 0 },
42182 {"SCREENDATATILEWARPOVFLAGS", SCREENDATATILEWARPOVFLAGS, 0, 0 },
42183 {"SCREENDATADOORCOMBOSET", SCREENDATADOORCOMBOSET, 0, 0 },
42184 {"SCREENDATAWARPRETX", SCREENDATAWARPRETX, 0, 0 },
42185 {"SCREENDATAWARPRETY", SCREENDATAWARPRETY, 0, 0 },
42186 {"SCREENDATAWARPRETURNC", SCREENDATAWARPRETURNC, 0, 0 },
42187 {"SCREENDATASTAIRX", SCREENDATASTAIRX, 0, 0 },
42188 {"SCREENDATASTAIRY", SCREENDATASTAIRY, 0, 0 },
42189 {"SCREENDATACOLOUR", SCREENDATACOLOUR, 0, 0 },
42190 {"SCREENDATAENEMYFLAGS", SCREENDATAENEMYFLAGS, 0, 0 },
42191 {"SCREENDATADOOR", SCREENDATADOOR, 0, 0 },
42192 {"SCREENDATATILEWARPDMAP", SCREENDATATILEWARPDMAP, 0, 0 },
42193 {"SCREENDATATILEWARPSCREEN", SCREENDATATILEWARPSCREEN, 0, 0 },
42194 {"SCREENDATAEXITDIR", SCREENDATAEXITDIR, 0, 0 },
42195 {"SCREENDATAENEMY", SCREENDATAENEMY, 0, 0 },
42196 {"SCREENDATAPATTERN", SCREENDATAPATTERN, 0, 0 },
42197 {"SCREENDATASIDEWARPTYPE", SCREENDATASIDEWARPTYPE, 0, 0 },
42198 {"SCREENDATASIDEWARPOVFLAGS", SCREENDATASIDEWARPOVFLAGS, 0, 0 },
42199 {"SCREENDATAWARPARRIVALX", SCREENDATAWARPARRIVALX, 0, 0 },
42200 {"SCREENDATAWARPARRIVALY", SCREENDATAWARPARRIVALY, 0, 0 },
42201 {"SCREENDATAPATH", SCREENDATAPATH, 0, 0 },
42202 {"SCREENDATASIDEWARPSC", SCREENDATASIDEWARPSC, 0, 0 },
42203 {"SCREENDATASIDEWARPDMAP", SCREENDATASIDEWARPDMAP, 0, 0 },
42204 {"SCREENDATASIDEWARPINDEX", SCREENDATASIDEWARPINDEX, 0, 0 },
42205 {"SCREENDATAUNDERCOMBO", SCREENDATAUNDERCOMBO, 0, 0 },
42206 {"SCREENDATAUNDERCSET", SCREENDATAUNDERCSET, 0, 0 },
42207 {"SCREENDATACATCHALL", SCREENDATACATCHALL, 0, 0 },
42208 {"SCREENDATAFLAGS", SCREENDATAFLAGS, 0, 0 },
42209 {"SCREENDATACSENSITIVE", SCREENDATACSENSITIVE, 0, 0 },
42210 {"SCREENDATANORESET", SCREENDATANORESET, 0, 0 },
42211 {"SCREENDATANOCARRY", SCREENDATANOCARRY, 0, 0 },
42212 {"SCREENDATALAYERMAP", SCREENDATALAYERMAP, 0, 0 },
42213 {"SCREENDATALAYERSCREEN", SCREENDATALAYERSCREEN, 0, 0 },
42214 {"SCREENDATALAYEROPACITY", SCREENDATALAYEROPACITY, 0, 0 },
42215 {"SCREENDATATIMEDWARPTICS", SCREENDATATIMEDWARPTICS, 0, 0 },
42216 {"SCREENDATANEXTMAP", SCREENDATANEXTMAP, 0, 0 },
42217 {"SCREENDATANEXTSCREEN", SCREENDATANEXTSCREEN, 0, 0 },
42218 {"SCREENDATASECRETCOMBO", SCREENDATASECRETCOMBO, 0, 0 },
42219 {"SCREENDATASECRETCSET", SCREENDATASECRETCSET, 0, 0 },
42220 {"SCREENDATASECRETFLAG", SCREENDATASECRETFLAG, 0, 0 },
42221 {"SCREENDATAVIEWX", SCREENDATAVIEWX, 0, 0 },
42222 {"SCREENDATAVIEWY", SCREENDATAVIEWY, 0, 0 },
42223 {"SCREENDATASCREENWIDTH", SCREENDATASCREENWIDTH, 0, 0 },
42224 {"SCREENDATASCREENHEIGHT", SCREENDATASCREENHEIGHT, 0, 0 },
42225 {"SCREENDATAENTRYX", SCREENDATAENTRYX, 0, 0 },
42226 {"SCREENDATAENTRYY", SCREENDATAENTRYY, 0, 0 },
42227 {"SCREENDATANUMFF", SCREENDATANUMFF, 0, 0 },
42228 {"SCREENDATAFFDATA", SCREENDATAFFDATA, 0, 0 },
42229 {"SCREENDATAFFCSET", SCREENDATAFFCSET, 0, 0 },
42230 {"SCREENDATAFFDELAY", SCREENDATAFFDELAY, 0, 0 },
42231 {"SCREENDATAFFX", SCREENDATAFFX, 0, 0 },
42232 {"SCREENDATAFFY", SCREENDATAFFY, 0, 0 },
42233 {"SCREENDATAFFXDELTA", SCREENDATAFFXDELTA, 0, 0 },
42234 {"SCREENDATAFFYDELTA", SCREENDATAFFYDELTA, 0, 0 },
42235 {"SCREENDATAFFXDELTA2", SCREENDATAFFXDELTA2, 0, 0 },
42236 {"SCREENDATAFFYDELTA2", SCREENDATAFFYDELTA2, 0, 0 },
42237 {"SCREENDATAFFFLAGS", SCREENDATAFFFLAGS, 0, 0 },
42238 {"SCREENDATAFFWIDTH", SCREENDATAFFWIDTH, 0, 0 },
42239 {"SCREENDATAFFHEIGHT", SCREENDATAFFHEIGHT, 0, 0 },
42240 {"SCREENDATAFFLINK", SCREENDATAFFLINK, 0, 0 },
42241 {"SCREENDATAFFSCRIPT", SCREENDATAFFSCRIPT, 0, 0 },
42242 {"SCREENDATAINTID", SCREENDATAINTID, 0, 0 }, //Needs to be a function [32][10]
42243 {"SCREENDATAINITA", SCREENDATAINITA, 0, 0 }, //needs to be a function, [32][2]
42244 {"SCREENDATAFFINITIALISED", SCREENDATAFFINITIALISED, 0, 0 },
42245 {"SCREENDATASCRIPTENTRY", SCREENDATASCRIPTENTRY, 0, 0 },
42246 {"SCREENDATASCRIPTOCCUPANCY", SCREENDATASCRIPTOCCUPANCY, 0, 0 },
42247 {"SCREENDATASCRIPTEXIT", SCREENDATASCRIPTEXIT, 0, 0 },
42248 {"SCREENDATAOCEANSFX", SCREENDATAOCEANSFX, 0, 0 },
42249 {"SCREENDATABOSSSFX", SCREENDATABOSSSFX, 0, 0 },
42250 {"SCREENDATASECRETSFX", SCREENDATASECRETSFX, 0, 0 },
42251 {"SCREENDATAHOLDUPSFX", SCREENDATAHOLDUPSFX, 0, 0 },
42252 {"SCREENDATASCREENMIDI", SCREENDATASCREENMIDI, 0, 0 },
42253 {"SCREENDATALENSLAYER", SCREENDATALENSLAYER, 0, 0 },
42254
42255 {"LINKSCRIPTTILE", LINKSCRIPTTILE, 0, 0 },
42256 {"LINKSCRIPFLIP", LINKSCRIPFLIP, 0, 0 },
42257 {"MAPDATAITEMX", MAPDATAITEMX, 0, 0 },
42258 {"MAPDATAITEMY", MAPDATAITEMY, 0, 0 },
42259 {"SCREENDATAITEMX", SCREENDATAITEMX, 0, 0 },
42260 {"SCREENDATAITEMY", SCREENDATAITEMY, 0, 0 },
42261
42262 {"MAPDATAFFEFFECTWIDTH", MAPDATAFFEFFECTWIDTH, 0, 0 },
42263 {"MAPDATAFFEFFECTHEIGHT", MAPDATAFFEFFECTHEIGHT, 0, 0 },
42264 {"SCREENDATAFFEFFECTWIDTH", SCREENDATAFFEFFECTWIDTH, 0, 0 },
42265 {"SCREENDATAFFEFFECTHEIGHT", SCREENDATAFFEFFECTHEIGHT, 0, 0 },
42266
42267 {"LOADMAPDATA", LOADMAPDATA, 0, 0 },
42268 {"LWPNPARENT", LWPNPARENT, 0, 0 },
42269 {"LWPNLEVEL", LWPNLEVEL, 0, 0 },
42270 {"EWPNLEVEL", EWPNLEVEL, 0, 0 },
42271 {"EWPNPARENT", EWPNPARENT, 0, 0 },
42272
42273
42274 {"SHOPDATANAME", SHOPDATANAME, 0, 0 },
42275 {"SHOPDATAITEM", SHOPDATAITEM, 0, 0 },
42276 {"SHOPDATAHASITEM", SHOPDATAHASITEM, 0, 0 },
42277 {"SHOPDATAPRICE", SHOPDATAPRICE, 0, 0 },
42278 {"SHOPDATASTRING", SHOPDATASTRING, 0, 0 },
42279
42280 {"NPCDATASHIELD", NPCDATASHIELD, 0, 0 },
42281 {"NPCSHIELD", NPCSHIELD, 0, 0 },
42282 {"AUDIOVOLUME", AUDIOVOLUME, 0, 0 },
42283 {"AUDIOPAN", AUDIOPAN, 0, 0 },
42284
42285 {"MESSAGEDATANEXT", MESSAGEDATANEXT, 0, 0 },
42286 {"MESSAGEDATATILE", MESSAGEDATATILE, 0, 0 },
42287 {"MESSAGEDATACSET", MESSAGEDATACSET, 0, 0 },
42288 {"MESSAGEDATATRANS", MESSAGEDATATRANS, 0, 0 },
42289 {"MESSAGEDATAFONT", MESSAGEDATAFONT, 0, 0 },
42290 {"MESSAGEDATAX", MESSAGEDATAX, 0, 0 },
42291 {"MESSAGEDATAY", MESSAGEDATAY, 0, 0 },
42292 {"MESSAGEDATAW", MESSAGEDATAW, 0, 0 },
42293 {"MESSAGEDATAH", MESSAGEDATAH, 0, 0 },
42294 {"MESSAGEDATASFX", MESSAGEDATASFX, 0, 0 },
42295 {"MESSAGEDATALISTPOS", MESSAGEDATALISTPOS, 0, 0 },
42296 {"MESSAGEDATAVSPACE", MESSAGEDATAVSPACE, 0, 0 },
42297 {"MESSAGEDATAHSPACE", MESSAGEDATAHSPACE, 0, 0 },
42298 {"MESSAGEDATAFLAGS", MESSAGEDATAFLAGS, 0, 0 },
42299
42300 {"DMAPDATAMAP", DMAPDATAMAP, 0, 0 },
42301 {"DMAPDATALEVEL", DMAPDATALEVEL, 0, 0 },
42302 {"DMAPDATAOFFSET", DMAPDATAOFFSET, 0, 0 },
42303 {"DMAPDATACOMPASS", DMAPDATACOMPASS, 0, 0 },
42304 {"DMAPDATAPALETTE", DMAPDATAPALETTE, 0, 0 },
42305 {"DMAPDATAMIDI", DMAPDATAMIDI, 0, 0 },
42306 {"DMAPDATACONTINUE", DMAPDATACONTINUE, 0, 0 },
42307 {"DMAPDATATYPE", DMAPDATATYPE, 0, 0 },
42308 {"DMAPDATAGRID", DMAPDATAGRID, 0, 0 },
42309 {"DMAPDATAMINIMAPTILE", DMAPDATAMINIMAPTILE, 0, 0 },
42310 {"DMAPDATAMINIMAPCSET", DMAPDATAMINIMAPCSET, 0, 0 },
42311 {"DMAPDATALARGEMAPTILE", DMAPDATALARGEMAPTILE, 0, 0 },
42312 {"DMAPDATALARGEMAPCSET", DMAPDATALARGEMAPCSET, 0, 0 },
42313 {"DMAPDATAMUISCTRACK", DMAPDATAMUISCTRACK, 0, 0 },
42314 {"DMAPDATASUBSCRA", DMAPDATASUBSCRA, 0, 0 },
42315 {"DMAPDATASUBSCRP", DMAPDATASUBSCRP, 0, 0 },
42316 {"DMAPDATADISABLEDITEMS", DMAPDATADISABLEDITEMS, 0, 0 },
42317 {"DMAPDATAFLAGS", DMAPDATAFLAGS, 0, 0 },
42318
42319 {"NPCFROZEN", NPCFROZEN, 0, 0 },
42320 {"NPCFROZENTILE", NPCFROZENTILE, 0, 0 },
42321 {"NPCFROZENCSET", NPCFROZENCSET, 0, 0 },
42322
42323 {"ITEMPSTRING", ITEMPSTRING, 0, 0 },
42324 {"ITEMPSTRINGFLAGS", ITEMPSTRINGFLAGS, 0, 0 },
42325 {"ITEMOVERRIDEFLAGS", ITEMOVERRIDEFLAGS, 0, 0 },
42326 {"LINKPUSH", LINKPUSH, 0, 0 },
42327 {"LINKSTUN", LINKSTUN, 0, 0 },
42328 {"IDATACOSTCOUNTER", IDATACOSTCOUNTER, 0, 0 },
42329 {"TYPINGMODE", TYPINGMODE, 0, 0 },
42330 // {"DMAPDATAGRAVITY", DMAPDATAGRAVITY, 0, 0 },
42331 // {"DMAPDATAJUMPLAYER", DMAPDATAJUMPLAYER, 0, 0 },
42332 //end ffscript vars
42333 //END VARS END OF BYTECODE
42334
42335 //newcombo
42336 {"COMBODTILE", COMBODTILE, 0, 0 },
42337 {"COMBODFLIP", COMBODFLIP, 0, 0 },
42338 {"COMBODWALK", COMBODWALK, 0, 0 },
42339 {"COMBODTYPE", COMBODTYPE, 0, 0 },
42340 {"COMBODCSET", COMBODCSET, 0, 0 },
42341 {"COMBODFOO", COMBODFOO, 0, 0 },
42342 {"COMBODFRAMES", COMBODFRAMES, 0, 0 },
42343 {"COMBODNEXTD", COMBODNEXTD, 0, 0 },
42344 {"COMBODNEXTC", COMBODNEXTC, 0, 0 },
42345 {"COMBODFLAG", COMBODFLAG, 0, 0 },
42346 {"COMBODSKIPANIM", COMBODSKIPANIM, 0, 0 },
42347 {"COMBODNEXTTIMER", COMBODNEXTTIMER, 0, 0 },
42348 {"COMBODAKIMANIMY", COMBODAKIMANIMY, 0, 0 },
42349 {"COMBODANIMFLAGS", COMBODANIMFLAGS, 0, 0 },
42350 {"COMBODEXPANSION", COMBODEXPANSION, 0, 0 },
42351 {"COMBODATTRIBUTES", COMBODATTRIBUTES, 0, 0 },
42352 {"COMBODATTRIBYTES", COMBODATTRIBYTES, 0, 0 },
42353 {"COMBODUSRFLAGS", COMBODUSRFLAGS, 0, 0 },
42354 {"COMBODTRIGGERFLAGS", COMBODTRIGGERFLAGS, 0, 0 },
42355 {"COMBODTRIGGERLEVEL", COMBODTRIGGERLEVEL, 0, 0 },
42356
42357 //comboclass
42358 {"COMBODNAME", COMBODNAME, 0, 0 },
42359 {"COMBODBLOCKNPC", COMBODBLOCKNPC, 0, 0 },
42360 {"COMBODBLOCKHOLE", COMBODBLOCKHOLE, 0, 0 },
42361 {"COMBODBLOCKTRIG", COMBODBLOCKTRIG, 0, 0 },
42362 {"COMBODBLOCKWEAPON", COMBODBLOCKWEAPON, 0, 0 },
42363 {"COMBODCONVXSPEED", COMBODCONVXSPEED, 0, 0 },
42364 {"COMBODCONVYSPEED", COMBODCONVYSPEED, 0, 0 },
42365 {"COMBODSPAWNNPC", COMBODSPAWNNPC, 0, 0 },
42366 {"COMBODSPAWNNPCWHEN", COMBODSPAWNNPCWHEN, 0, 0 },
42367 {"COMBODSPAWNNPCCHANGE", COMBODSPAWNNPCCHANGE, 0, 0 },
42368 {"COMBODDIRCHANGETYPE", COMBODDIRCHANGETYPE, 0, 0 },
42369 {"COMBODDISTANCECHANGETILES", COMBODDISTANCECHANGETILES, 0, 0 },
42370 {"COMBODDIVEITEM", COMBODDIVEITEM, 0, 0 },
42371 {"COMBODDOCK", COMBODDOCK, 0, 0 },
42372 {"COMBODFAIRY", COMBODFAIRY, 0, 0 },
42373 {"COMBODFFATTRCHANGE", COMBODFFATTRCHANGE, 0, 0 },
42374 {"COMBODFOORDECOTILE", COMBODFOORDECOTILE, 0, 0 },
42375 {"COMBODFOORDECOTYPE", COMBODFOORDECOTYPE, 0, 0 },
42376 {"COMBODHOOKSHOTPOINT", COMBODHOOKSHOTPOINT, 0, 0 },
42377 {"COMBODLADDERPASS", COMBODLADDERPASS, 0, 0 },
42378 {"COMBODLOCKBLOCK", COMBODLOCKBLOCK, 0, 0 },
42379 {"COMBODLOCKBLOCKCHANGE", COMBODLOCKBLOCKCHANGE, 0, 0 },
42380 {"COMBODMAGICMIRROR", COMBODMAGICMIRROR, 0, 0 },
42381 {"COMBODMODHPAMOUNT", COMBODMODHPAMOUNT, 0, 0 },
42382 {"COMBODMODHPDELAY", COMBODMODHPDELAY, 0, 0 },
42383 {"COMBODMODHPTYPE", COMBODMODHPTYPE, 0, 0 },
42384 {"COMBODNMODMPAMOUNT", COMBODNMODMPAMOUNT, 0, 0 },
42385 {"COMBODMODMPDELAY", COMBODMODMPDELAY, 0, 0 },
42386 {"COMBODMODMPTYPE", COMBODMODMPTYPE, 0, 0 },
42387 {"COMBODNOPUSHBLOCK", COMBODNOPUSHBLOCK, 0, 0 },
42388 {"COMBODOVERHEAD", COMBODOVERHEAD, 0, 0 },
42389 {"COMBODPLACENPC", COMBODPLACENPC, 0, 0 },
42390 {"COMBODPUSHDIR", COMBODPUSHDIR, 0, 0 },
42391 {"COMBODPUSHWAIT", COMBODPUSHWAIT, 0, 0 },
42392 {"COMBODPUSHHEAVY", COMBODPUSHHEAVY, 0, 0 },
42393 {"COMBODPUSHED", COMBODPUSHED, 0, 0 },
42394 {"COMBODRAFT", COMBODRAFT, 0, 0 },
42395 {"COMBODRESETROOM", COMBODRESETROOM, 0, 0 },
42396 {"COMBODSAVEPOINTTYPE", COMBODSAVEPOINTTYPE, 0, 0 },
42397 {"COMBODSCREENFREEZETYPE", COMBODSCREENFREEZETYPE, 0, 0 },
42398 {"COMBODSECRETCOMBO", COMBODSECRETCOMBO, 0, 0 },
42399 {"COMBODSINGULAR", COMBODSINGULAR, 0, 0 },
42400 {"COMBODSLOWWALK", COMBODSLOWWALK, 0, 0 },
42401 {"COMBODSTATUETYPEs", COMBODSTATUETYPE, 0, 0 },
42402 {"COMBODSTEPTYPE", COMBODSTEPTYPE, 0, 0 },
42403 {"COMBODSTEPCHANGEINTO", COMBODSTEPCHANGEINTO, 0, 0 },
42404 {"COMBODSTRIKEWEAPONS", COMBODSTRIKEWEAPONS, 0, 0 },
42405 {"COMBODSTRIKEREMNANTS", COMBODSTRIKEREMNANTS, 0, 0 },
42406 {"COMBODSTRIKEREMNANTSTYPE", COMBODSTRIKEREMNANTSTYPE, 0, 0 },
42407 {"COMBODSTRIKECHANGE", COMBODSTRIKECHANGE, 0, 0 },
42408 {"COMBODSTRIKEITEM", COMBODSTRIKEITEM, 0, 0 },
42409 {"COMBODTOUCHITEM", COMBODTOUCHITEM, 0, 0 },
42410 {"COMBODTOUCHSTAIRS", COMBODTOUCHSTAIRS, 0, 0 },
42411 {"COMBODTRIGGERTYPE", COMBODTRIGGERTYPE, 0, 0 },
42412 {"COMBODTRIGGERSENS", COMBODTRIGGERSENS, 0, 0 },
42413 {"COMBODWARPTYPE", COMBODWARPTYPE, 0, 0 },
42414 {"COMBODWARPSENS", COMBODWARPSENS, 0, 0 },
42415 {"COMBODWARPDIRECT", COMBODWARPDIRECT, 0, 0 },
42416 {"COMBODWARPLOCATION", COMBODWARPLOCATION, 0, 0 },
42417 {"COMBODWATER", COMBODWATER, 0, 0 },
42418 {"COMBODWHISTLE", COMBODWHISTLE, 0, 0 },
42419 {"COMBODWINGAME", COMBODWINGAME, 0, 0 },
42420 {"COMBODBLOCKWPNLEVEL", COMBODBLOCKWPNLEVEL, 0, 0 },
42421
42422 {"TYPINGMODE", TYPINGMODE, 0, 0 },
42423 {"TYPINGMODE", TYPINGMODE, 0, 0 },
42424 {"LINKHITBY", LINKHITBY, 0, 0 },
42425 {"LINKDEFENCE", LINKDEFENCE, 0, 0 },
42426 {"NPCHITBY", NPCHITBY, 0, 0 },
42427 {"NPCISCORE", NPCISCORE, 0, 0 },
42428 {"NPCSCRIPTUID", NPCSCRIPTUID, 0, 0 },
42429 {"LWEAPONSCRIPTUID", LWEAPONSCRIPTUID, 0, 0 },
42430 {"EWEAPONSCRIPTUID", EWEAPONSCRIPTUID, 0, 0 },
42431 {"ITEMSCRIPTUID", ITEMSCRIPTUID, 0, 0 },
42432
42433 {"DMAPDATASIDEVIEW", DMAPDATASIDEVIEW, 0, 0 },
42434
42435 {"DONULL", DONULL, 0, 0 },
42436 {"DEBUGD", DEBUGD, 0, 0 },
42437 {"GETPIXEL", GETPIXEL, 0, 0 },
42438 {"DOUNTYPE", DOUNTYPE, 0, 0 },
42439 {"NPCBEHAVIOUR", NPCBEHAVIOUR, 0, 0 },
42440 {"NPCDATABEHAVIOUR", NPCDATABEHAVIOUR, 0, 0 },
42441 {"CREATEBITMAP", CREATEBITMAP, 0, 0 },
42442 {"LINKTILEMOD", LINKTILEMOD, 0, 0 },
42443 {"NPCINITD", NPCINITD, 0, 0 },
42444 {"NPCCOLLISION", NPCCOLLISION, 0, 0 },
42445 {"NPCLINEDUP", NPCLINEDUP, 0, 0 },
42446
42447 {"NPCDATAINITD", NPCLINEDUP, 0, 0 },
42448 {"NPCDATASCRIPT", NPCDATASCRIPT, 0, 0 },
42449 {"NPCMATCHINITDLABEL", NPCMATCHINITDLABEL, 0, 0 },
42450 //lweapon scripts
42451 {"LWPNSCRIPT", LWPNSCRIPT, 0, 0 },
42452 {"LWPNINITD", LWPNINITD, 0, 0 },
42453 {"ITEMFAMILY", ITEMFAMILY, 0, 0 },
42454 {"ITEMLEVEL", ITEMLEVEL, 0, 0 },
42455
42456 {"EWPNSCRIPT", EWPNSCRIPT, 0, 0 },
42457 {"EWPNINITD", EWPNINITD, 0, 0 },
42458
42459 {"NPCSCRIPT", NPCSCRIPT, 0, 0 },
42460
42461 {"DMAPSCRIPT", DMAPSCRIPT, 0, 0 },
42462 {"DMAPINITD", DMAPINITD, 0, 0 },
42463
42464 {"SCREENSCRIPT", SCREENSCRIPT, 0, 0 },
42465 {"SCREENINITD", SCREENINITD, 0, 0 },
42466
42467 {"LINKINITD", LINKINITD, 0, 0 },
42468 {"NPCDATAWEAPONINITD", NPCDATAWEAPONINITD, 0, 0 },
42469 {"NPCDATAWEAPONSCRIPT", NPCDATAWEAPONSCRIPT, 0, 0 },
42470
42471 {"NPCSCRIPTTILE", NPCSCRIPTTILE, 0, 0 },
42472 {"NPCSCRIPTFLIP", NPCSCRIPTFLIP, 0, 0 },
42473 {"LWPNSCRIPTTILE", LWPNSCRIPTTILE, 0, 0 },
42474 {"LWPNSCRIPTFLIP", LWPNSCRIPTFLIP, 0, 0 },
42475 {"EWPNSCRIPTTILE", EWPNSCRIPTTILE, 0, 0 },
42476 {"EWPNSCRIPTFLIP", EWPNSCRIPTFLIP, 0, 0 },
42477
42478 {"LINKENGINEANIMATE", LINKENGINEANIMATE, 0, 0 },
42479 {"NPCENGINEANIMATE", NPCENGINEANIMATE, 0, 0 },
42480 {"LWPNENGINEANIMATE", LWPNENGINEANIMATE, 0, 0 },
42481 {"EWPNENGINEANIMATE", EWPNENGINEANIMATE, 0, 0 },
42482 {"SKIPCREDITS", SKIPCREDITS, 0, 0 },
42483 {"SKIPF6", SKIPF6, 0, 0 },
42484 {"LWPNUSEWEAPON", LWPNUSEWEAPON, 0, 0 },
42485 {"LWPNUSEDEFENCE", LWPNUSEDEFENCE, 0, 0 },
42486 {"LWPNROTATION", LWPNROTATION, 0, 0 },
42487 {"EWPNROTATION", EWPNROTATION, 0, 0 },
42488 {"NPCROTATION", NPCROTATION, 0, 0 },
42489 {"ITEMROTATION", ITEMROTATION, 0, 0 },
42490 {"LINKROTATION", LINKROTATION, 0, 0 },
42491 {"LWPNSCALE", LWPNSCALE, 0, 0 },
42492 {"EWPNSCALE", EWPNSCALE, 0, 0 },
42493 {"NPCSCALE", NPCSCALE, 0, 0 },
42494 {"ITEMSCALE", ITEMSCALE, 0, 0 },
42495 {"LINKSCALE", LINKSCALE, 0, 0 },
42496 {"ITEMSPRITESCRIPT", ITEMSPRITESCRIPT, 0, 0 },
42497 {"FFRULE", FFRULE, 0, 0 },
42498 {"NUMDRAWS", NUMDRAWS, 0, 0 },
42499 {"MAXDRAWS", MAXDRAWS, 0, 0 },
42500 {"BITMAPWIDTH", BITMAPWIDTH, 0, 0 },
42501 {"BITMAPHEIGHT", BITMAPHEIGHT, 0, 0 },
42502 {"ALLOCATEBITMAPR", ALLOCATEBITMAPR, 0, 0 },
42503 {"KEYMODIFIERS", KEYMODIFIERS, 0, 0 },
42504 {"SIMULATEKEYPRESS", SIMULATEKEYPRESS, 0, 0 },
42505 {"KEYBINDINGS", KEYBINDINGS, 0, 0 },
42506
42507 {"SCREENSCRIPT", SCREENSCRIPT, 0, 0 },
42508 {"SCREENINITD", SCREENINITD, 0, 0 },
42509 {"MAPDATASCRIPT", MAPDATASCRIPT, 0, 0 },
42510 {"MAPDATAINITDARRAY", MAPDATAINITDARRAY, 0, 0 },
42511 {"LWPNGRAVITY", LWPNGRAVITY, 0, 0 },
42512 {"EWPNGRAVITY", EWPNGRAVITY, 0, 0 },
42513 {"NPCGRAVITY", NPCGRAVITY, 0, 0 },
42514 {"ITEMGRAVITY", ITEMGRAVITY, 0, 0 },
42515
42516 {"MAPDATASIDEWARPID", MAPDATASIDEWARPID, 0, 0 },
42517 {"SCREENSIDEWARPID", SCREENSIDEWARPID, 0, 0 },
42518 {"SCREENDATALAYERINVIS", SCREENDATALAYERINVIS, 0, 0 },
42519 {"SCREENDATASCRIPTDRAWS", SCREENDATASCRIPTDRAWS, 0, 0 },
42520 {"MAPDATALAYERINVIS", MAPDATALAYERINVIS, 0, 0 },
42521 {"MAPDATASCRIPTDRAWS", MAPDATASCRIPTDRAWS, 0, 0 },
42522
42523 {"ITEMSCRIPTTILE", ITEMSCRIPTTILE, 0, 0 },
42524 {"ITEMSCRIPTFLIP", ITEMSCRIPTFLIP, 0, 0 },
42525 {"MAPDATAMAP", MAPDATAMAP, 0, 0 },
42526 {"MAPDATASCREEN", MAPDATASCREEN, 0, 0 },
42527 {"IDATAVALIDATE", IDATAVALIDATE, 0, 0 },
42528 { "DISABLEKEY", DISABLEKEY, 0, 0 },
42529 { "DISABLEBUTTON", DISABLEBUTTON, 0, 0 },
42530 { "GAMESUSPEND", GAMESUSPEND, 0, 0 },
42531 { "LINKOTILE", LINKOTILE, 0, 0 },
42532 { "LINKOFLIP", LINKOFLIP, 0, 0 },
42533 { "ITEMSPRITEINITD", ITEMSPRITEINITD, 0, 0 },
42534
42535 { "ZSCRIPTVERSION", ZSCRIPTVERSION, 0, 0 },
42536 { "REFFILE", REFFILE, 0, 0 },
42537 { "LINKCLIMBING", LINKCLIMBING, 0, 0 },
42538 { "NPCIMMORTAL", NPCIMMORTAL, 0, 0 },
42539 { "NPCNOSLIDE", NPCNOSLIDE, 0, 0 },
42540 { "NPCKNOCKBACKSPEED", NPCKNOCKBACKSPEED, 0, 0 },
42541 { "NPCNOSCRIPTKB", NPCNOSCRIPTKB, 0, 0 },
42542 { "GETRENDERTARGET", GETRENDERTARGET, 0, 0 },
42543 { "HERONOSTEPFORWARD", HERONOSTEPFORWARD, 0, 0 },
42544 { "SCREENDATATWARPRETSQR", SCREENDATATWARPRETSQR, 0, 0 },
42545 { "SCREENDATASWARPRETSQR", SCREENDATASWARPRETSQR, 0, 0 },
42546 { "MAPDATATWARPRETSQR", MAPDATATWARPRETSQR, 0, 0 },
42547 { "MAPDATASWARPRETSQR", MAPDATASWARPRETSQR, 0, 0 },
42548 { "NPCSUBMERGED", NPCSUBMERGED, 0, 0 },
42549 { "GAMEGRAVITY", GAMEGRAVITY, 0, 0 },
42550 { "COMBODASPEED", COMBODASPEED, 0, 0 },
42551 { "DROPSETITEMS", DROPSETITEMS, 0, 0 },
42552 { "DROPSETCHANCES", DROPSETCHANCES, 0, 0 },
42553 { "DROPSETNULLCHANCE", DROPSETNULLCHANCE, 0, 0 },
42554 { "DROPSETCHOOSE", DROPSETCHOOSE, 0, 0 },
42555 { "NPCPARENTUID", NPCPARENTUID, 0, 0 },
42556 { "KEYPRESS", KEYPRESS, 0, 0 },
42557 { "KEYINPUT", KEYINPUT, 0, 0 },
42558 { "SPRITEMAXNPC", SPRITEMAXNPC, 0, 0 },
42559 { "SPRITEMAXLWPN", SPRITEMAXLWPN, 0, 0 },
42560 { "SPRITEMAXEWPN", SPRITEMAXEWPN, 0, 0 },
42561 { "SPRITEMAXITEM", SPRITEMAXITEM, 0, 0 },
42562 { "SPRITEMAXPARTICLE", SPRITEMAXPARTICLE, 0, 0 },
42563 { "SPRITEMAXDECO", SPRITEMAXDECO, 0, 0 },
42564 { "HEROHEALTHBEEP", HEROHEALTHBEEP, 0, 0 },
42565 { "NPCRANDOM", NPCRANDOM, 0, 0 },
42566 { "COMBOXR", COMBOXR, 0, 0 },
42567 { "COMBOYR", COMBOYR, 0, 0 },
42568 { "COMBOPOSR", COMBOPOSR, 0, 0 },
42569 { "COMBODATASCRIPT", COMBODATASCRIPT, 0, 0 },
42570 { "COMBODATAINITD", COMBODATAINITD, 0, 0 },
42571 { "HEROSCRIPTCSET", HEROSCRIPTCSET, 0, 0 },
42572 { "SHOPDATATYPE", SHOPDATATYPE, 0, 0 },
42573 { "HEROSTEPS", HEROSTEPS, 0, 0 },
42574 { "HEROSTEPRATE", HEROSTEPRATE, 0, 0 },
42575 { "COMBODOTILE", COMBODOTILE, 0, 0 },
42576 { "COMBODFRAME", COMBODFRAME, 0, 0 },
42577 { "COMBODACLK", COMBODACLK, 0, 0 },
42578 { "PC", PC, 0, 0 },
42579 { "GAMESCROLLING", GAMESCROLLING, 0, 0 },
42580 { "MESSAGEDATAMARGINS", MESSAGEDATAMARGINS, 0, 0 },
42581 { "MESSAGEDATAPORTTILE", MESSAGEDATAPORTTILE, 0, 0 },
42582 { "MESSAGEDATAPORTCSET", MESSAGEDATAPORTCSET, 0, 0 },
42583 { "MESSAGEDATAPORTX", MESSAGEDATAPORTX, 0, 0 },
42584 { "MESSAGEDATAPORTY", MESSAGEDATAPORTY, 0, 0 },
42585 { "MESSAGEDATAPORTWID", MESSAGEDATAPORTWID, 0, 0 },
42586 { "MESSAGEDATAPORTHEI", MESSAGEDATAPORTHEI, 0, 0 },
42587 { "MESSAGEDATAFLAGSARR", MESSAGEDATAFLAGSARR, 0, 0 },
42588 { "FILEPOS", FILEPOS, 0, 0 },
42589 { "FILEEOF", FILEEOF, 0, 0 },
42590 { "FILEERR", FILEERR, 0, 0 },
42591 { "MESSAGEDATATEXTWID", MESSAGEDATATEXTWID, 0, 0 },
42592 { "MESSAGEDATATEXTHEI", MESSAGEDATATEXTHEI, 0, 0 },
42593 { "SWITCHKEY", SWITCHKEY, 0, 0 },
42594 { "INCQST", INCQST, 0, 0 },
42595 { "HEROJUMPCOUNT", HEROJUMPCOUNT, 0, 0 },
42596 { "HEROPULLDIR", HEROPULLDIR, 0, 0 },
42597 { "HEROPULLCLK", HEROPULLCLK, 0, 0 },
42598 { "HEROFALLCLK", HEROFALLCLK, 0, 0 },
42599 { "HEROFALLCMB", HEROFALLCMB, 0, 0 },
42600 { "HEROMOVEFLAGS", HEROMOVEFLAGS, 0, 0 },
42601 { "ITEMFALLCLK", ITEMFALLCLK, 0, 0 },
42602 { "ITEMFALLCMB", ITEMFALLCMB, 0, 0 },
42603 { "ITEMMOVEFLAGS", ITEMMOVEFLAGS, 0, 0 },
42604 { "LWPNFALLCLK", LWPNFALLCLK, 0, 0 },
42605 { "LWPNFALLCMB", LWPNFALLCMB, 0, 0 },
42606 { "LWPNMOVEFLAGS", LWPNMOVEFLAGS, 0, 0 },
42607 { "EWPNFALLCLK", EWPNFALLCLK, 0, 0 },
42608 { "EWPNFALLCMB", EWPNFALLCMB, 0, 0 },
42609 { "EWPNMOVEFLAGS", EWPNMOVEFLAGS, 0, 0 },
42610 { "NPCFALLCLK", NPCFALLCLK, 0, 0 },
42611 { "NPCFALLCMB", NPCFALLCMB, 0, 0 },
42612 { "NPCMOVEFLAGS", NPCMOVEFLAGS, 0, 0 },
42613 { "ISBLANKTILE", ISBLANKTILE, 0, 0 },
42614 { "LWPNSPECIAL", LWPNSPECIAL, 0, 0 },
42615 { "DMAPDATAASUBSCRIPT", DMAPDATAASUBSCRIPT, 0, 0 },
42616 { "DMAPDATAPSUBSCRIPT", DMAPDATAPSUBSCRIPT, 0, 0 },
42617 { "DMAPDATASUBINITD", DMAPDATASUBINITD, 0, 0 },
42618 { "MODULEGETINT", MODULEGETINT, 0, 0 },
42619 { "MODULEGETSTR", MODULEGETSTR, 0, 0 },
42620 { "NPCORIGINALHP", NPCORIGINALHP, 0, 0 },
42621 { "DMAPDATAMAPSCRIPT", DMAPDATAMAPSCRIPT, 0, 0 },
42622 { "DMAPDATAMAPINITD", DMAPDATAMAPINITD, 0, 0 },
42623 { "CLOCKCLK", CLOCKCLK, 0, 0 },
42624 { "CLOCKACTIVE", CLOCKACTIVE, 0, 0 },
42625 { "NPCHITDIR", NPCHITDIR, 0, 0 },
42626 { "DMAPDATAFLAGARR", DMAPDATAFLAGARR, 0, 0 },
42627 { "LINKCSET", LINKCSET, 0, 0 },
42628 { "NPCSLIDECLK", NPCSLIDECLK, 0, 0 },
42629 { "NPCFADING", NPCFADING, 0, 0 },
42630 { "DISTANCE", DISTANCE, 0, 0 },
42631 { "STDARR", STDARR, 0, 0 },
42632 { "GHOSTARR", GHOSTARR, 0, 0 },
42633 { "TANGOARR", TANGOARR, 0, 0 },
42634 { "NPCHALTCLK", NPCHALTCLK, 0, 0 },
42635 { "NPCMOVESTATUS", NPCMOVESTATUS, 0, 0 },
42636 { "DISTANCESCALE", DISTANCESCALE, 0, 0 },
42637 { "DMAPDATACHARTED", DMAPDATACHARTED, 0, 0 },
42638 { "REFDIRECTORY", REFDIRECTORY, 0, 0 },
42639 { "DIRECTORYSIZE", DIRECTORYSIZE, 0, 0 },
42640 { "LONGDISTANCE", LONGDISTANCE, 0, 0 },
42641 { "LONGDISTANCESCALE", LONGDISTANCESCALE, 0, 0 },
42642 { "COMBOED", COMBOED, 0, 0 },
42643 { "MAPDATACOMBOED", MAPDATACOMBOED, 0, 0 },
42644 { "COMBODEFFECT", COMBODEFFECT, 0, 0 },
42645 { "SCREENSECRETSTRIGGERED", SCREENSECRETSTRIGGERED, 0, 0 },
42646 { "ITEMDIR", ITEMDIR, 0, 0 },
42647 { "NPCFRAME", NPCFRAME, 0, 0 },
42648 { "LINKITEMX", LINKITEMX, 0, 0 },
42649 { "LINKITEMY", LINKITEMY, 0, 0 },
42650 { "ACTIVESSSPEED", ACTIVESSSPEED, 0, 0 },
42651 { "HEROISWARPING", HEROISWARPING, 0, 0 },
42652 { "ITEMGLOWRAD", ITEMGLOWRAD, 0, 0 },
42653 { "NPCGLOWRAD", NPCGLOWRAD, 0, 0 },
42654 { "LWPNGLOWRAD", LWPNGLOWRAD, 0, 0 },
42655 { "EWPNGLOWRAD", EWPNGLOWRAD, 0, 0 },
42656 { "ITEMGLOWSHP", ITEMGLOWSHP, 0, 0 },
42657 { "NPCGLOWSHP", NPCGLOWSHP, 0, 0 },
42658 { "LWPNGLOWSHP", LWPNGLOWSHP, 0, 0 },
42659 { "EWPNGLOWSHP", EWPNGLOWSHP, 0, 0 },
42660 { "ITEMENGINEANIMATE", ITEMENGINEANIMATE, 0, 0 },
42661 { "REFRNG", REFRNG, 0, 0 },
42662 { "LWPNUNBL", LWPNUNBL, 0, 0 },
42663 { "EWPNUNBL", EWPNUNBL, 0, 0 },
42664 { "NPCSHADOWSPR", NPCSHADOWSPR, 0, 0 },
42665 { "LWPNSHADOWSPR", LWPNSHADOWSPR, 0, 0 },
42666 { "EWPNSHADOWSPR", EWPNSHADOWSPR, 0, 0 },
42667 { "ITEMSHADOWSPR", ITEMSHADOWSPR, 0, 0 },
42668 { "NPCSPAWNSPR", NPCSPAWNSPR, 0, 0 },
42669 { "NPCDEATHSPR", NPCDEATHSPR, 0, 0 },
42670 { "NPCDSHADOWSPR", NPCDSHADOWSPR, 0, 0 },
42671 { "NPCDSPAWNSPR", NPCDSPAWNSPR, 0, 0 },
42672 { "NPCDDEATHSPR", NPCDDEATHSPR, 0, 0 },
42673
42674 { "COMBOLAYERR", COMBOLAYERR, 0, 0 },
42675 { "COMBODATTRISHORTS", COMBODATTRISHORTS, 0, 0 },
42676
42677 { "PUSHBLOCKLAYER", PUSHBLOCKLAYER, 0, 0 },
42678 { "LINKGRABBED", LINKGRABBED, 0, 0 },
42679 { "HEROBUNNY", HEROBUNNY, 0, 0 },
42680
42681 { "GAMELSWITCH", GAMELSWITCH, 0, 0 },
42682 { "GAMEBOTTLEST", GAMEBOTTLEST, 0, 0 },
42683
42684 { "REFBOTTLETYPE", REFBOTTLETYPE, 0, 0 },
42685 { "REFBOTTLESHOP", REFBOTTLESHOP, 0, 0 },
42686 { "BOTTLECOUNTER", BOTTLECOUNTER, 0, 0 },
42687 { "BOTTLEAMOUNT", BOTTLEAMOUNT, 0, 0 },
42688 { "BOTTLEPERCENT", BOTTLEPERCENT, 0, 0 },
42689 { "BOTTLEFLAGS", BOTTLEFLAGS, 0, 0 },
42690 { "BOTTLENEXT", BOTTLENEXT, 0, 0 },
42691 { "BSHOPFILL", BSHOPFILL, 0, 0 },
42692 { "BSHOPCOMBO", BSHOPCOMBO, 0, 0 },
42693 { "BSHOPCSET", BSHOPCSET, 0, 0 },
42694 { "BSHOPPRICE", BSHOPPRICE, 0, 0 },
42695 { "BSHOPSTR", BSHOPSTR, 0, 0 },
42696 { "COMBODUSRFLAGARR", COMBODUSRFLAGARR, 0, 0 },
42697 { "COMBODGENFLAGARR", COMBODGENFLAGARR, 0, 0 },
42698 { "HERORESPAWNX", HERORESPAWNX, 0, 0 },
42699 { "HERORESPAWNY", HERORESPAWNY, 0, 0 },
42700 { "HERORESPAWNDMAP", HERORESPAWNDMAP, 0, 0 },
42701 { "HERORESPAWNSCR", HERORESPAWNSCR, 0, 0 },
42702 { "IDATAUSESOUND2", IDATAUSESOUND2, 0, 0 },
42703 { "HEROSWITCHTIMER", HEROSWITCHTIMER, 0, 0 },
42704 { "HEROSWITCHMAXTIMER", HEROSWITCHMAXTIMER, 0, 0 },
42705 { "NPCSWHOOKED", NPCSWHOOKED, 0, 0 },
42706 { "GAMEMISCSPR", GAMEMISCSPR, 0, 0 },
42707 { "GAMEMISCSFX", GAMEMISCSFX, 0, 0 },
42708 { "HEROTOTALDYOFFS", HEROTOTALDYOFFS, 0, 0 },
42709 { "NPCTOTALDYOFFS", NPCTOTALDYOFFS, 0, 0 },
42710 { "LWPNTOTALDYOFFS", LWPNTOTALDYOFFS, 0, 0 },
42711 { "EWPNTOTALDYOFFS", EWPNTOTALDYOFFS, 0, 0 },
42712 { "LWSWHOOKED", LWSWHOOKED, 0, 0 },
42713 { "EWSWHOOKED", EWSWHOOKED, 0, 0 },
42714 { "ITMSWHOOKED", ITMSWHOOKED, 0, 0 },
42715 { "DEBUGTESTING", DEBUGTESTING, 0, 0 },
42716 { "GAMEMAXCHEAT", GAMEMAXCHEAT, 0, 0 },
42717 { "SHOWNMSG", SHOWNMSG, 0, 0 },
42718 { "COMBODTRIGGERBUTTON", COMBODTRIGGERBUTTON, 0, 0 },
42719 { "REFGENERICDATA", REFGENERICDATA, 0, 0 },
42720 { "GENDATARUNNING", GENDATARUNNING, 0, 0 },
42721 { "GENDATASIZE", GENDATASIZE, 0, 0 },
42722 { "GENDATAEXITSTATE", GENDATAEXITSTATE, 0, 0 },
42723 { "GENDATADATA", GENDATADATA, 0, 0 },
42724 { "GENDATAINITD", GENDATAINITD, 0, 0 },
42725 { "GENDATARELOADSTATE", GENDATARELOADSTATE, 0, 0 },
42726 { "COMBODCSET2FLAGS", COMBODCSET2FLAGS, 0, 0 },
42727 { "HEROIMMORTAL", HEROIMMORTAL, 0, 0 },
42728 { "NPCCANFLICKER", NPCCANFLICKER, 0, 0 },
42729 { "NPCDROWNCLK", NPCDROWNCLK, 0, 0 },
42730 { "NPCDROWNCMB", NPCDROWNCMB, 0, 0 },
42731 { "ITEMDROWNCLK", ITEMDROWNCLK, 0, 0 },
42732 { "ITEMDROWNCMB", ITEMDROWNCMB, 0, 0 },
42733 { "LWPNDROWNCLK", LWPNDROWNCLK, 0, 0 },
42734 { "LWPNDROWNCMB", LWPNDROWNCMB, 0, 0 },
42735 { "EWPNDROWNCLK", EWPNDROWNCLK, 0, 0 },
42736 { "EWPNDROWNCMB", EWPNDROWNCMB, 0, 0 },
42737 { "HERODROWNCLK", HERODROWNCLK, 0, 0 },
42738 { "HERODROWNCMB", HERODROWNCMB, 0, 0 },
42739 { "NPCFAKEZ", NPCFAKEZ, 0, 0 },
42740 { "ITEMFAKEZ", ITEMFAKEZ, 0, 0 },
42741 { "LWPNFAKEZ", LWPNFAKEZ, 0, 0 },
42742 { "EWPNFAKEZ", EWPNFAKEZ, 0, 0 },
42743 { "HEROFAKEZ", HEROFAKEZ, 0, 0 },
42744 { "NPCFAKEJUMP", NPCFAKEJUMP, 0, 0 },
42745 { "ITEMFAKEJUMP", ITEMFAKEJUMP, 0, 0 },
42746 { "LWPNFAKEJUMP", LWPNFAKEJUMP, 0, 0 },
42747 { "EWPNFAKEJUMP", EWPNFAKEJUMP, 0, 0 },
42748 { "HEROFAKEJUMP", HEROFAKEJUMP, 0, 0 },
42749 { "HEROSHADOWXOFS", HEROSHADOWXOFS, 0, 0 },
42750 { "HEROSHADOWYOFS", HEROSHADOWYOFS, 0, 0 },
42751 { "NPCSHADOWXOFS", NPCSHADOWXOFS, 0, 0 },
42752 { "NPCSHADOWYOFS", NPCSHADOWYOFS, 0, 0 },
42753 { "ITEMSHADOWXOFS", ITEMSHADOWXOFS, 0, 0 },
42754 { "ITEMSHADOWYOFS", ITEMSHADOWYOFS, 0, 0 },
42755 { "LWPNSHADOWXOFS", LWPNSHADOWXOFS, 0, 0 },
42756 { "LWPNSHADOWYOFS", LWPNSHADOWYOFS, 0, 0 },
42757 { "EWPNSHADOWXOFS", EWPNSHADOWXOFS, 0, 0 },
42758 { "EWPNSHADOWYOFS", EWPNSHADOWYOFS, 0, 0 },
42759 { "LWPNDEGANGLE", LWPNDEGANGLE, 0, 0 },
42760 { "EWPNDEGANGLE", EWPNDEGANGLE, 0, 0 },
42761 { "LWPNVX", LWPNVX, 0, 0 },
42762 { "LWPNVY", LWPNVY, 0, 0 },
42763 { "EWPNVX", EWPNVX, 0, 0 },
42764 { "EWPNVY", EWPNVY, 0, 0 },
42765 { "LWPNAUTOROTATE", LWPNAUTOROTATE, 0, 0 },
42766 { "EWPNAUTOROTATE", EWPNAUTOROTATE, 0, 0 },
42767 { "IDATACOSTCOUNTER2", IDATACOSTCOUNTER2, 0, 0 },
42768 { "IDATAMAGICTIMER2", IDATAMAGICTIMER2, 0, 0 },
42769 { "IDATACOST2", IDATACOST2, 0, 0 },
42770 { "IDATAVALIDATE2", IDATAVALIDATE2, 0, 0 },
42771 { "MESSAGEDATATEXTLEN", MESSAGEDATATEXTLEN, 0, 0 },
42772 { "LWPNFLAGS", LWPNFLAGS, 0, 0 },
42773 { "EWPNFLAGS", EWPNFLAGS, 0, 0 },
42774 { "REFSTACK", REFSTACK, 0, 0 },
42775 { "STACKSIZE", STACKSIZE, 0, 0 },
42776 { "STACKFULL", STACKFULL, 0, 0 },
42777 { "ITEMFORCEGRAB", ITEMFORCEGRAB, 0, 0 },
42778 { "COMBODTRIGGERITEM", COMBODTRIGGERITEM, 0, 0 },
42779 { "COMBODTRIGGERTIMER", COMBODTRIGGERTIMER, 0, 0 },
42780 { "COMBODTRIGGERSFX", COMBODTRIGGERSFX, 0, 0 },
42781 { "COMBODTRIGGERCHANGECMB", COMBODTRIGGERCHANGECMB, 0, 0 },
42782 { "SCREENEXSTATED", SCREENEXSTATED, 0, 0 },
42783 { "MAPDATAEXSTATED", MAPDATAEXSTATED, 0, 0 },
42784 { "HEROSTANDING", HEROSTANDING, 0, 0 },
42785 { "COMBODTRIGGERPROX", COMBODTRIGGERPROX, 0, 0 },
42786 { "COMBODTRIGGERLIGHTBEAM", COMBODTRIGGERLIGHTBEAM, 0, 0 },
42787 { "COMBODTRIGGERCTR", COMBODTRIGGERCTR, 0, 0 },
42788 { "COMBODTRIGGERCTRAMNT", COMBODTRIGGERCTRAMNT, 0, 0 },
42789 { "GENDATAEVENTSTATE", GENDATAEVENTSTATE, 0, 0 },
42790 { "GAMEEVENTDATA", GAMEEVENTDATA, 0, 0 },
42791 { "ITEMDROPPEDBY", ITEMDROPPEDBY, 0, 0 },
42792 { "GAMEGSWITCH", GAMEGSWITCH, 0, 0 },
42793
42794 { "COMBODTRIGGERCOOLDOWN", COMBODTRIGGERCOOLDOWN, 0, 0 },
42795 { "COMBODTRIGGERCOPYCAT", COMBODTRIGGERCOPYCAT, 0, 0 },
42796 { "COMBODTRIGITEMPICKUP", COMBODTRIGITEMPICKUP, 0, 0 },
42797 { "COMBODTRIGEXSTATE", COMBODTRIGEXSTATE, 0, 0 },
42798 { "COMBODTRIGSPAWNENEMY", COMBODTRIGSPAWNENEMY, 0, 0 },
42799 { "COMBODTRIGSPAWNITEM", COMBODTRIGSPAWNITEM, 0, 0 },
42800 { "COMBODTRIGCSETCHANGE", COMBODTRIGCSETCHANGE, 0, 0 },
42801 { "COMBODLIFTGFXCOMBO", COMBODLIFTGFXCOMBO, 0, 0 },
42802 { "COMBODLIFTGFXCCSET", COMBODLIFTGFXCCSET, 0, 0 },
42803 { "COMBODLIFTUNDERCMB", COMBODLIFTUNDERCMB, 0, 0 },
42804 { "COMBODLIFTUNDERCS", COMBODLIFTUNDERCS, 0, 0 },
42805 { "COMBODLIFTDAMAGE", COMBODLIFTDAMAGE, 0, 0 },
42806 { "COMBODLIFTLEVEL", COMBODLIFTLEVEL, 0, 0 },
42807 { "COMBODLIFTITEM", COMBODLIFTITEM, 0, 0 },
42808 { "COMBODLIFTFLAGS", COMBODLIFTFLAGS, 0, 0 },
42809 { "COMBODLIFTGFXTYPE", COMBODLIFTGFXTYPE, 0, 0 },
42810 { "COMBODLIFTGFXSPRITE", COMBODLIFTGFXSPRITE, 0, 0 },
42811 { "COMBODLIFTSFX", COMBODLIFTSFX, 0, 0 },
42812 { "COMBODLIFTBREAKSPRITE", COMBODLIFTBREAKSPRITE, 0, 0 },
42813 { "COMBODLIFTBREAKSFX", COMBODLIFTBREAKSFX, 0, 0 },
42814 { "COMBODLIFTHEIGHT", COMBODLIFTHEIGHT, 0, 0 },
42815 { "COMBODLIFTTIME", COMBODLIFTTIME, 0, 0 },
42816 { "CLASS_THISKEY", CLASS_THISKEY, 0, 0 },
42817 { "ZELDABETATYPE", ZELDABETATYPE, 0, 0 },
42818 { "HEROCOYOTETIME", HEROCOYOTETIME, 0, 0 },
42819 { "FFCLASTCHANGERX", FFCLASTCHANGERX, 0, 0 },
42820 { "FFCLASTCHANGERY", FFCLASTCHANGERY, 0, 0 },
42821 { "LWPNTIMEOUT", LWPNTIMEOUT, 0, 0 },
42822 { "EWPNTIMEOUT", EWPNTIMEOUT, 0, 0 },
42823 { "COMBODTRIGGERLSTATE", COMBODTRIGGERLSTATE, 0, 0 },
42824 { "COMBODTRIGGERGSTATE", COMBODTRIGGERGSTATE, 0, 0 },
42825 { "COMBODTRIGGERGTIMER", COMBODTRIGGERGTIMER, 0, 0 },
42826 { "GAMEMOUSECURSOR", GAMEMOUSECURSOR, 0, 0 },
42827 { "COMBODTRIGGERGENSCRIPT", COMBODTRIGGERGENSCRIPT, 0, 0 },
42828 { "COMBODTRIGGERGROUP", COMBODTRIGGERGROUP, 0, 0 },
42829 { "COMBODTRIGGERGROUPVAL", COMBODTRIGGERGROUPVAL, 0, 0 },
42830 { "HEROLIFTEDWPN", HEROLIFTEDWPN, 0, 0 },
42831 { "HEROLIFTTIMER", HEROLIFTTIMER, 0, 0 },
42832 { "HEROLIFTMAXTIMER", HEROLIFTMAXTIMER, 0, 0 },
42833 { "HEROLIFTHEIGHT", HEROLIFTHEIGHT, 0, 0 },
42834 { "HEROHAMMERSTATE", HEROHAMMERSTATE, 0, 0 },
42835 { "HEROLIFTFLAGS", HEROLIFTFLAGS, 0, 0 },
42836 { "COMBODLIFTWEAPONITEM", COMBODLIFTWEAPONITEM, 0, 0 },
42837 { "LWPNDEATHITEM", LWPNDEATHITEM, 0, 0 },
42838 { "LWPNDEATHDROPSET", LWPNDEATHDROPSET, 0, 0 },
42839 { "LWPNDEATHIPICKUP", LWPNDEATHIPICKUP, 0, 0 },
42840 { "LWPNDEATHSPRITE", LWPNDEATHSPRITE, 0, 0 },
42841 { "LWPNDEATHSFX", LWPNDEATHSFX, 0, 0 },
42842 { "EWPNDEATHITEM", EWPNDEATHITEM, 0, 0 },
42843 { "EWPNDEATHDROPSET", EWPNDEATHDROPSET, 0, 0 },
42844 { "EWPNDEATHIPICKUP", EWPNDEATHIPICKUP, 0, 0 },
42845 { "EWPNDEATHSPRITE", EWPNDEATHSPRITE, 0, 0 },
42846 { "EWPNDEATHSFX", EWPNDEATHSFX, 0, 0 },
42847
42848 { "REFPALDATA", REFPALDATA, 0, 0 },
42849
42850 { "PALDATACOLOR", PALDATACOLOR, 0, 0 },
42851 { "PALDATAR", PALDATAR, 0, 0 },
42852 { "PALDATAG", PALDATAG, 0, 0 },
42853 { "PALDATAB", PALDATAB, 0, 0 },
42854
42855 { "DMAPDATALOOPSTART", DMAPDATALOOPSTART, 0, 0 },
42856 { "DMAPDATALOOPEND", DMAPDATALOOPEND, 0, 0 },
42857 { "DMAPDATAXFADEIN", DMAPDATAXFADEIN, 0, 0 },
42858 { "DMAPDATAXFADEOUT", DMAPDATAXFADEOUT, 0, 0 },
42859 { "MUSICUPDATECOND", MUSICUPDATECOND, 0, 0 },
42860 { "MUSICUPDATEFLAGS", MUSICUPDATEFLAGS, 0, 0 },
42861 { "RESRVD_VAR_MOOSH07", RESRVD_VAR_MOOSH07, 0, 0 },
42862 { "RESRVD_VAR_MOOSH08", RESRVD_VAR_MOOSH08, 0, 0 },
42863 { "RESRVD_VAR_MOOSH09", RESRVD_VAR_MOOSH09, 0, 0 },
42864 { "RESRVD_VAR_MOOSH10", RESRVD_VAR_MOOSH10, 0, 0 },
42865 { "RESRVD_VAR_MOOSH11", RESRVD_VAR_MOOSH11, 0, 0 },
42866 { "RESRVD_VAR_MOOSH12", RESRVD_VAR_MOOSH12, 0, 0 },
42867 { "RESRVD_VAR_MOOSH13", RESRVD_VAR_MOOSH13, 0, 0 },
42868 { "RESRVD_VAR_MOOSH14", RESRVD_VAR_MOOSH14, 0, 0 },
42869 { "RESRVD_VAR_MOOSH15", RESRVD_VAR_MOOSH15, 0, 0 },
42870 { "RESRVD_VAR_MOOSH16", RESRVD_VAR_MOOSH16, 0, 0 },
42871 { "RESRVD_VAR_MOOSH17", RESRVD_VAR_MOOSH17, 0, 0 },
42872 { "RESRVD_VAR_MOOSH18", RESRVD_VAR_MOOSH18, 0, 0 },
42873 { "RESRVD_VAR_MOOSH19", RESRVD_VAR_MOOSH19, 0, 0 },
42874 { "RESRVD_VAR_MOOSH20", RESRVD_VAR_MOOSH20, 0, 0 },
42875 { "RESRVD_VAR_MOOSH21", RESRVD_VAR_MOOSH21, 0, 0 },
42876 { "RESRVD_VAR_MOOSH22", RESRVD_VAR_MOOSH22, 0, 0 },
42877 { "RESRVD_VAR_MOOSH23", RESRVD_VAR_MOOSH23, 0, 0 },
42878 { "RESRVD_VAR_MOOSH24", RESRVD_VAR_MOOSH24, 0, 0 },
42879 { "RESRVD_VAR_MOOSH25", RESRVD_VAR_MOOSH25, 0, 0 },
42880 { "RESRVD_VAR_MOOSH26", RESRVD_VAR_MOOSH26, 0, 0 },
42881 { "RESRVD_VAR_MOOSH27", RESRVD_VAR_MOOSH27, 0, 0 },
42882 { "RESRVD_VAR_MOOSH28", RESRVD_VAR_MOOSH28, 0, 0 },
42883 { "RESRVD_VAR_MOOSH29", RESRVD_VAR_MOOSH29, 0, 0 },
42884 { "RESRVD_VAR_MOOSH30", RESRVD_VAR_MOOSH30, 0, 0 },
42885 { "DMAPDATAMIRRDMAP", DMAPDATAMIRRDMAP, 0, 0 },
42886 { "IDATAGRADUAL", IDATAGRADUAL, 0, 0 },
42887 { "IDATASPRSCRIPT", IDATASPRSCRIPT, 0, 0 },
42888 { "IDATAPSOUND", IDATAPSOUND, 0, 0 },
42889 { "IDATACONSTSCRIPT", IDATACONSTSCRIPT, 0, 0 },
42890 { "IDATASSWIMDISABLED", IDATASSWIMDISABLED, 0, 0 },
42891 { "IDATABUNNYABLE", IDATABUNNYABLE, 0, 0 },
42892 { "IDATAJINXIMMUNE", IDATAJINXIMMUNE, 0, 0 },
42893 { "IDATAJINXSWAP", IDATAJINXSWAP, 0, 0 },
42894 { "SPRITEDATAFLCSET", SPRITEDATAFLCSET, 0, 0 },
42895 { "SPRITEDATAFLAGS", SPRITEDATAFLAGS, 0, 0 },
42896 { "SPRITEDATAID", SPRITEDATAID, 0, 0 },
42897 { "CLASS_THISKEY2", CLASS_THISKEY2, 0, 0 },
42898 { "RESRVD_VAR_Z3_01", RESRVD_VAR_Z3_01, 0, 0 },
42899 { "RESRVD_VAR_Z3_02", RESRVD_VAR_Z3_02, 0, 0 },
42900 { "RESRVD_VAR_Z3_03", RESRVD_VAR_Z3_03, 0, 0 },
42901 { "RESRVD_VAR_Z3_04", RESRVD_VAR_Z3_04, 0, 0 },
42902 { "RESRVD_VAR_Z3_05", RESRVD_VAR_Z3_05, 0, 0 },
42903 { "RESRVD_VAR_Z3_06", RESRVD_VAR_Z3_06, 0, 0 },
42904 { "RESRVD_VAR_Z3_07", RESRVD_VAR_Z3_07, 0, 0 },
42905 { "RESRVD_VAR_Z3_08", RESRVD_VAR_Z3_08, 0, 0 },
42906 { "RESRVD_VAR_Z3_09", RESRVD_VAR_Z3_09, 0, 0 },
42907 { "RESRVD_VAR_Z3_10", RESRVD_VAR_Z3_10, 0, 0 },
42908 { "RESRVD_VAR_Z3_11", RESRVD_VAR_Z3_11, 0, 0 },
42909 { "RESRVD_VAR_Z3_12", RESRVD_VAR_Z3_12, 0, 0 },
42910 { "RESRVD_VAR_Z3_13", RESRVD_VAR_Z3_13, 0, 0 },
42911 { "RESRVD_VAR_Z3_14", RESRVD_VAR_Z3_14, 0, 0 },
42912 { "RESRVD_VAR_Z3_15", RESRVD_VAR_Z3_15, 0, 0 },
42913 { "RESRVD_VAR_Z3_16", RESRVD_VAR_Z3_16, 0, 0 },
42914 { "LWPNLIFTLEVEL", LWPNLIFTLEVEL, 0, 0},
42915 { "LWPNLIFTTIME", LWPNLIFTTIME, 0, 0},
42916 { "LWPNLIFTHEIGHT", LWPNLIFTHEIGHT, 0, 0},
42917 { "EWPNLIFTLEVEL", EWPNLIFTLEVEL, 0, 0},
42918 { "EWPNLIFTTIME", EWPNLIFTTIME, 0, 0},
42919 { "EWPNLIFTHEIGHT", EWPNLIFTHEIGHT, 0, 0},
42920 { "HEROSHIELDJINX", HEROSHIELDJINX, 0, 0},
42921 { "MAPDATALENSSHOWS", MAPDATALENSSHOWS, 0, 0},
42922 { "MAPDATALENSHIDES", MAPDATALENSHIDES, 0, 0},
42923 { "SCREENLENSSHOWS", SCREENLENSSHOWS, 0, 0},
42924 { "SCREENLENSHIDES", SCREENLENSHIDES, 0, 0},
42925 { "GAMETRIGGROUPS", GAMETRIGGROUPS, 0, 0},
42926 { "RESRVD_VAR_EMILY43", RESRVD_VAR_EMILY43, 0, 0},
42927 { "RESRVD_VAR_EMILY44", RESRVD_VAR_EMILY44, 0, 0},
42928 { "RESRVD_VAR_EMILY45", RESRVD_VAR_EMILY45, 0, 0},
42929 { "RESRVD_VAR_EMILY46", RESRVD_VAR_EMILY46, 0, 0},
42930 { "RESRVD_VAR_EMILY47", RESRVD_VAR_EMILY47, 0, 0},
42931 { "RESRVD_VAR_EMILY48", RESRVD_VAR_EMILY48, 0, 0},
42932 { "RESRVD_VAR_EMILY49", RESRVD_VAR_EMILY49, 0, 0},
42933 { "RESRVD_VAR_EMILY50", RESRVD_VAR_EMILY50, 0, 0},
42934 { "RESRVD_VAR_EMILY51", RESRVD_VAR_EMILY51, 0, 0},
42935 { "RESRVD_VAR_EMILY52", RESRVD_VAR_EMILY52, 0, 0},
42936 { "RESRVD_VAR_EMILY53", RESRVD_VAR_EMILY53, 0, 0},
42937 { "RESRVD_VAR_EMILY54", RESRVD_VAR_EMILY54, 0, 0},
42938 { "RESRVD_VAR_EMILY55", RESRVD_VAR_EMILY55, 0, 0},
42939 { "RESRVD_VAR_EMILY56", RESRVD_VAR_EMILY56, 0, 0},
42940 { "RESRVD_VAR_EMILY57", RESRVD_VAR_EMILY57, 0, 0},
42941 { "RESRVD_VAR_EMILY58", RESRVD_VAR_EMILY58, 0, 0},
42942 { "RESRVD_VAR_EMILY59", RESRVD_VAR_EMILY59, 0, 0},
42943 { "RESRVD_VAR_EMILY60", RESRVD_VAR_EMILY60, 0, 0},
42944 { "PORTALX", PORTALX, 0, 0},
42945 { "PORTALY", PORTALY, 0, 0},
42946 { "PORTALDMAP", PORTALDMAP, 0, 0},
42947 { "PORTALSCREEN", PORTALSCREEN, 0, 0},
42948 { "PORTALACLK", PORTALACLK, 0, 0},
42949 { "PORTALAFRM", PORTALAFRM, 0, 0},
42950 { "PORTALOTILE", PORTALOTILE, 0, 0},
42951 { "PORTALASPD", PORTALASPD, 0, 0},
42952 { "PORTALFRAMES", PORTALFRAMES, 0, 0},
42953 { "PORTALSAVED", PORTALSAVED, 0, 0},
42954 { "PORTALCLOSEDIS", PORTALCLOSEDIS, 0, 0},
42955 { "REFPORTAL", REFPORTAL, 0, 0},
42956 { "REFSAVPORTAL", REFSAVPORTAL, 0, 0},
42957 { "PORTALWARPSFX", PORTALWARPSFX, 0, 0},
42958 { "PORTALWARPVFX", PORTALWARPVFX, 0, 0},
42959 { "SAVEDPORTALX", SAVEDPORTALX, 0, 0},
42960 { "SAVEDPORTALY", SAVEDPORTALY, 0, 0},
42961 { "SAVEDPORTALSRCDMAP", SAVEDPORTALSRCDMAP, 0, 0},
42962 { "SAVEDPORTALDESTDMAP", SAVEDPORTALDESTDMAP, 0, 0},
42963 { "SAVEDPORTALSRCSCREEN", SAVEDPORTALSRCSCREEN, 0, 0},
42964 { "SAVEDPORTALWARPSFX", SAVEDPORTALWARPSFX, 0, 0},
42965 { "SAVEDPORTALWARPVFX", SAVEDPORTALWARPVFX, 0, 0},
42966 { "SAVEDPORTALSPRITE", SAVEDPORTALSPRITE, 0, 0},
42967 { "SAVEDPORTALPORTAL", SAVEDPORTALPORTAL, 0, 0},
42968 { "PORTALCOUNT", PORTALCOUNT, 0, 0},
42969 { "SAVEDPORTALCOUNT", SAVEDPORTALCOUNT, 0, 0},
42970 { "SAVEDPORTALDSTSCREEN", SAVEDPORTALDSTSCREEN, 0, 0},
42971
42972 { " ", -1, 0, 0 }
42973 };
42974
42975
42976
42977 ///----------------------------------------------------------------------------------------------------//
42978 //Debugger and Logging Consoles
42979
42980 template <typename ...Params>
42981 void FFScript::ZScriptConsole(int32_t attributes,const char *format, Params&&... params)
42982 {
42983 //if ( open )
42984 {
42985 zscript_coloured_console.Create("ZQuest Creator Logging Console", 600, 200, NULL, NULL);
42986 zscript_coloured_console.cls(CConsoleLoggerEx::COLOR_BACKGROUND_BLACK);
42987 zscript_coloured_console.gotoxy(0,0);
42988 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
42989 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"ZQuest Creator Logging Console\n");
42990
42991 zscript_coloured_console.cprintf( attributes, format, std::forward<Params>(params)...);
42992 }
42993 //else
42994 //{
42995 //close
42996 // zscript_coloured_console.Close();
42997 //}
42998 }
42999
43000 122 void clearConsole()
43001 {
43002 122 zscript_coloured_console.cls(CConsoleLoggerEx::COLOR_BACKGROUND_BLACK);
43003 122 zscript_coloured_console.gotoxy(0,0);
43004
43005 122 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_RED | CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
43006 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"\n _____ ____ __ \n");
43007 122 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_RED | CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
43008 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK," /__ / / __ \\__ _____ _____/ /_\n");
43009 122 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_RED | CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
43010 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK," / / / / / / / / / _ \\/ ___/ __/\n");
43011 122 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_RED | CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
43012 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK," / /__/ /_/ / /_/ / __(__ ) /_ \n");
43013 122 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_RED | CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
43014 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK," /____/\\___\\_\\__,_/\\___/____/\\__/\n\n");
43015
43016 122 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
43017 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"Quest Data Logging & ZScript Debug Console\n");
43018
43019 122 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE |CConsoleLoggerEx::COLOR_GREEN | CConsoleLoggerEx::COLOR_INTENSITY |
43020 122 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"Running: %s\n", getProgramVerStr());
43021
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 7 times.
122 if ( FFCore.getQuestHeaderInfo(vZelda) > 0 )
43022 {
43023 7 char const* verstr = QHeader.getVerStr();
43024
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(verstr[0])
43025 {
43026 7 auto vercmp = QHeader.compareVer();
43027 7 auto astatecmp = compare(int32_t(QHeader.getAlphaState()), ALPHA_STATE);
43028 7 auto avercmp = compare(QHeader.getAlphaVer(), ALPHA_VER);
43029 7 auto timecmp = QHeader.compareDate();
43030
5/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1 times.
7 if(!(vercmp || astatecmp || avercmp))
43031 {
43032
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(!timecmp || !QHeader.new_version_is_nightly)
43033 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE |CConsoleLoggerEx::COLOR_GREEN | CConsoleLoggerEx::COLOR_INTENSITY |
43034 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"Quest Made in this build\n", verstr);
43035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 else if(timecmp < 0)
43036 {
43037 1 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE |CConsoleLoggerEx::COLOR_GREEN | CConsoleLoggerEx::COLOR_INTENSITY |
43038 1 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"Quest Made in an earlier nightly of the same build\n", verstr);
43039 1 }
43040 else
43041 {
43042 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE |CConsoleLoggerEx::COLOR_GREEN | CConsoleLoggerEx::COLOR_INTENSITY |
43043 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"Quest Made in an LATER nightly of the same build!\n"
43044 "This may be unsafe to play in this version!\n", verstr);
43045 }
43046 1 }
43047 6 else zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE |CConsoleLoggerEx::COLOR_GREEN | CConsoleLoggerEx::COLOR_INTENSITY |
43048 6 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"Quest Made in: %s\n", verstr);
43049 7 }
43050 7 }
43051 122 }
43052 void FFScript::ZScriptConsole(bool open)
43053 {
43054 if ( open )
43055 {
43056 zscript_coloured_console.Create("ZScript Debug Console", 600, 200, NULL, NULL);
43057 clearConsole();
43058 zscript_debugger = 1;
43059 }
43060 else
43061 {
43062 zscript_coloured_console.Close();
43063 zscript_debugger = 0;
43064 }
43065 zc_set_config("CONSOLE","ZScript_Debugger",zscript_debugger);
43066 }
43067
43068 void FFScript::ZASMPrint(bool open)
43069 {
43070 if(SKIPZASMPRINT()) return;
43071 zprint("%s ZASM Console\n", open ? "Opening" : "Closing");
43072 if ( open )
43073 {
43074 coloured_console.Create("ZASM Debugger", 600, 200, NULL, NULL);
43075 coloured_console.cls(CConsoleLoggerEx::COLOR_BACKGROUND_BLACK);
43076 coloured_console.gotoxy(0,0);
43077 coloured_console.safeprint( CConsoleLoggerEx::COLOR_GREEN | CConsoleLoggerEx::COLOR_INTENSITY |
43078 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"ZASM Stack Trace:\n");
43079 //coloured_console.SetAsDefaultOutput();
43080 zasm_debugger = 1;
43081 zasm_break_mode = ZASM_BREAK_HALT;
43082 }
43083 else
43084 {
43085 //close
43086 coloured_console.Close();
43087 zasm_debugger = 0;
43088 }
43089 zc_set_config("CONSOLE","print_ZASM",zasm_debugger);
43090 }
43091
43092 std::string ZASMVarToString(int32_t arg)
43093 {
43094 for(int32_t q = 0; ZASMVars[q].id != -1; ++q)
43095 {
43096 if(ZASMVars[q].maxcount>0)
43097 {
43098 int32_t start = ZASMVars[q].id;
43099 int32_t mult = zc_max(1,ZASMVars[q].multiple);
43100 if(arg >= start && arg < start+(ZASMVars[q].maxcount*mult))
43101 {
43102 for(int32_t w = 0; w < ZASMVars[q].maxcount; ++w)
43103 {
43104 if(arg!=start+(w*mult)) continue;
43105
43106 char buf[64+1];
43107 if(strcmp(ZASMVars[q].name, "A")==0)
43108 sprintf(buf, "%s%d", ZASMVars[q].name, w+1);
43109 else sprintf(buf, "%s%d", ZASMVars[q].name, w);
43110 return string(buf);
43111 }
43112 }
43113 }
43114 else if(ZASMVars[q].id == arg) return string(ZASMVars[q].name);
43115 }
43116 return "(null)";
43117 }
43118
43119 void FFScript::ZASMPrintCommand(const word scommand)
43120 {
43121 if(SKIPZASMPRINT()) return;
43122 //if ( !zasm_debugger ) return;
43123
43124 script_command s_c = ZASMcommands[scommand];
43125
43126 if(s_c.args == 2)
43127 {
43128 coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
43129 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"%14s: ", s_c.name);
43130
43131 if(s_c.arg1_type == 0)
43132 {
43133 coloured_console.cprintf( CConsoleLoggerEx::COLOR_WHITE |
43134 //CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"%10s (val = %9d), ", s_v.name, get_register(sarg1));
43135 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"\t %s (val = %2d), ", ZASMVarToString(sarg1).c_str(), get_register(sarg1));
43136 }
43137 else
43138 {
43139 coloured_console.cprintf( CConsoleLoggerEx::COLOR_RED |CConsoleLoggerEx::COLOR_INTENSITY |
43140 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"%10s (val = %2d), ", "immediate", sarg1);
43141 }
43142 if(s_c.arg2_type == 0)
43143 {
43144 coloured_console.cprintf( CConsoleLoggerEx::COLOR_RED | CConsoleLoggerEx::COLOR_INTENSITY |
43145 //CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"%10s (val = %9d)\n", s_v.name, get_register(sarg2));
43146 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK, "\t %s (val = %2d)\n", ZASMVarToString(sarg2).c_str(), get_register(sarg2));
43147 }
43148 else
43149 {
43150 coloured_console.cprintf( CConsoleLoggerEx::COLOR_RED | CConsoleLoggerEx::COLOR_INTENSITY |
43151 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"%10s (val = %2d)\n", "immediate", sarg2);
43152 }
43153 }
43154 else if(s_c.args == 1)
43155 {
43156 coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
43157 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"%14s: ", s_c.name);
43158
43159 if(s_c.arg1_type == 0)
43160 {
43161 coloured_console.cprintf( CConsoleLoggerEx::COLOR_RED | CConsoleLoggerEx::COLOR_INTENSITY |
43162 //CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"%10s (val = %9d)\n", s_v.name, get_register(sarg1));
43163 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"\t %w (val = %2d)\n", ZASMVarToString(sarg1).c_str(), get_register(sarg1));
43164 }
43165 else
43166 {
43167 coloured_console.cprintf( CConsoleLoggerEx::COLOR_RED | CConsoleLoggerEx::COLOR_INTENSITY |
43168 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"%10s (val = %2d)\n", "immediate", sarg1);
43169 }
43170 }
43171 else
43172 {
43173 coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
43174 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"%14s\n",s_c.name);
43175 }
43176 //s_c.name is the string with the instruction
43177
43178 //coloured_console.print();
43179 }
43180
43181 void FFScript::ZASMPrintVarSet(const int32_t arg, int32_t argval)
43182 {
43183 if(SKIPZASMPRINT()) return;
43184
43185 //if ( !zasm_debugger ) return;
43186 // script_variable s_v = ZASMVars[arg];
43187 //s_v.name is the string with the instruction
43188 coloured_console.cprintf( CConsoleLoggerEx::COLOR_WHITE |
43189 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"Set: %s\t",ZASMVarToString(arg).c_str());
43190 coloured_console.cprintf( CConsoleLoggerEx::COLOR_GREEN | CConsoleLoggerEx::COLOR_INTENSITY |
43191 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"%d\n",argval);
43192 //coloured_console.print();
43193 }
43194
43195 void FFScript::ZASMPrintVarGet(const int32_t arg, int32_t argval)
43196 {
43197 if(SKIPZASMPRINT()) return;
43198
43199 //if ( !zasm_debugger ) return;
43200 // script_variable s_v = ZASMVars[arg];
43201 //s_v.name is the string with the instruction
43202 coloured_console.cprintf( CConsoleLoggerEx::COLOR_WHITE |
43203 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"Get: %s\t",ZASMVarToString(arg).c_str());
43204 coloured_console.cprintf( CConsoleLoggerEx::COLOR_GREEN | CConsoleLoggerEx::COLOR_INTENSITY |
43205 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"%d\n",argval);
43206 //coloured_console.print();
43207 }
43208
43209
43210
43211 ///----------------------------------------------------------------------------------------------------//
43212 //Tracing
43213
43214 3553 void FFScript::do_trace(bool v)
43215 {
43216 3553 int32_t temp = SH::get_arg(sarg1, v);
43217
43218 char tmp[100];
43219
1/2
✓ Branch 0 taken 3553 times.
✗ Branch 1 not taken.
3553 sprintf(tmp, (temp < 0 ? "%06d" : "%05d"), temp);
43220
1/2
✓ Branch 0 taken 3553 times.
✗ Branch 1 not taken.
3553 string s2(tmp);
43221
5/10
✓ Branch 0 taken 3553 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3553 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3553 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3553 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3553 times.
✗ Branch 9 not taken.
3553 s2 = s2.substr(0, s2.size() - 4) + "." + s2.substr(s2.size() - 4, 4) + "\n";
43222
1/2
✓ Branch 0 taken 3553 times.
✗ Branch 1 not taken.
3553 TraceScriptIDs();
43223
1/2
✓ Branch 0 taken 3553 times.
✗ Branch 1 not taken.
3553 al_trace("%s", s2.c_str());
43224
8/18
✓ Branch 0 taken 3553 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3553 times.
✓ Branch 4 taken 3553 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 3553 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 3553 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 3553 times.
✓ Branch 12 taken 9 times.
✓ Branch 13 taken 3544 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
7106 if (replay_is_active() && replay_get_meta_bool("script_trace"))
43225
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 replay_step_comment("trace: " + s2);
43226
43227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3553 times.
3553 if ( zscript_debugger )
43228 {
43229 zscript_coloured_console.safeprint((CConsoleLoggerEx::COLOR_WHITE |
43230 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK),s2.c_str());
43231 }
43232 3553 }
43233 void FFScript::do_tracel(bool v)
43234 {
43235 int32_t temp = SH::get_arg(sarg1, v);
43236
43237 char tmp[32];
43238 sprintf(tmp, "%d\n", temp);
43239 TraceScriptIDs();
43240 al_trace("%s", tmp);
43241 if (replay_is_active() && replay_get_meta_bool("script_trace"))
43242 replay_step_comment(fmt::format("trace: {}", temp));
43243
43244 if ( zscript_debugger )
43245 {
43246 zscript_coloured_console.safeprint((CConsoleLoggerEx::COLOR_WHITE |
43247 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK),tmp);
43248 }
43249 }
43250
43251 void FFScript::do_tracebool(const bool v)
43252 {
43253 int32_t temp = SH::get_arg(sarg1, v);
43254 TraceScriptIDs();
43255 char const* str = temp ? "true\n" : "false\n";
43256 al_trace("%s", str);
43257 if (replay_is_active() && replay_get_meta_bool("script_trace"))
43258 replay_step_comment(fmt::format("trace: {}", (bool)temp));
43259
43260 if ( zscript_debugger )
43261 {
43262 zscript_coloured_console.safeprint((CConsoleLoggerEx::COLOR_WHITE |
43263 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK),str);
43264 }
43265 }
43266
43267 3993 void traceStr(string const& str)
43268 {
43269 3993 FFCore.TraceScriptIDs();
43270 3993 safe_al_trace(str);
43271
7/16
✗ Branch 0 not taken.
✓ Branch 1 taken 3993 times.
✓ Branch 2 taken 3993 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3993 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 3993 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 3993 times.
✓ Branch 10 taken 671 times.
✓ Branch 11 taken 3322 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
7986 if (replay_is_active() && replay_get_meta_bool("script_trace"))
43272
1/2
✓ Branch 0 taken 3322 times.
✗ Branch 1 not taken.
3322 replay_step_comment("trace: " + str);
43273
43274
1/2
✓ Branch 0 taken 3993 times.
✗ Branch 1 not taken.
3993 if ( zscript_debugger )
43275 {
43276 zscript_coloured_console.safeprint((CConsoleLoggerEx::COLOR_WHITE |
43277 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK),str.c_str());
43278 }
43279 3993 }
43280
43281 384 void FFScript::do_tracestring()
43282 {
43283 384 int32_t arrayptr = get_register(sarg1) / 10000;
43284 384 string str;
43285
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 ArrayH::getString(arrayptr, str, 512);
43286
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 str += "\0"; //In the event that the user passed an array w/o NULL, don't crash.
43287
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 traceStr(str);
43288 384 }
43289
43290 bool is_valid_format(char c)
43291 {
43292 switch(c)
43293 {
43294 case 'f': case 'd': case 'i': case 'p':
43295 case 'l': case 's': case 'c': case 'X':
43296 case 'x': case 'b': case 'B': case 'a':
43297 return true;
43298 }
43299 return false;
43300 }
43301 18980 char const* zs_formatter(char const* format, int32_t arg, int32_t mindig)
43302 {
43303
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 18976 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
18980 static std::string ret;
43304
43305 18980 ret.clear();
43306
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18980 times.
18980 if(format)
43307 {
43308 18980 char mindigbuf[8] = {0};
43309
1/2
✓ Branch 0 taken 18980 times.
✗ Branch 1 not taken.
18980 if(mindig)
43310 sprintf(mindigbuf, "%%0%d%c", mindig,
43311 (format[0] == 'x' || format[0] == 'X') ? format[0] : 'd');
43312 18980 bool tempbool = false;
43313
2/12
✗ Branch 0 not taken.
✓ Branch 1 taken 18222 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 758 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
18980 switch(format[0])
43314 {
43315 case 'f':
43316 tempbool = true;
43317 [[fallthrough]];
43318 case 'd':
43319
2/2
✓ Branch 0 taken 17750 times.
✓ Branch 1 taken 472 times.
18694 if(arg%10000)
43320 472 tempbool = true;
43321 [[fallthrough]];
43322 case 'i':
43323 case 'p':
43324 {
43325 18222 char argbuf[32] = {0};
43326 18222 bool neg = arg < 0;
43327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18222 times.
18222 if(mindig)
43328 sprintf(argbuf,mindigbuf,arg / 10000);
43329 18222 else zc_itoa(arg / 10000, argbuf);
43330
43331
2/2
✓ Branch 0 taken 17750 times.
✓ Branch 1 taken 472 times.
18222 if(tempbool) //add decimal places
43332 {
43333 472 arg = abs(arg);
43334 472 auto ind = strlen(argbuf);
43335 472 argbuf[ind++] = '.';
43336
2/2
✓ Branch 0 taken 1888 times.
✓ Branch 1 taken 472 times.
2360 for(int div = 1000; div > 0; div /= 10)
43337 1888 argbuf[ind++] = '0' + (arg/div)%10;
43338
4/4
✓ Branch 0 taken 472 times.
✓ Branch 1 taken 244 times.
✓ Branch 2 taken 244 times.
✓ Branch 3 taken 472 times.
716 for(--ind; argbuf[ind]=='0' && argbuf[ind-1]!='-'; --ind)
43339 {
43340 244 argbuf[ind] = 0;
43341 244 }
43342 472 }
43343
43344
4/4
✓ Branch 0 taken 929 times.
✓ Branch 1 taken 17293 times.
✓ Branch 2 taken 877 times.
✓ Branch 3 taken 52 times.
18222 if(neg && argbuf[0] != '-')
43345 52 ret = "-";
43346 18222 ret += argbuf;
43347 18222 return ret.c_str();
43348 }
43349 //
43350 case 'l':
43351 {
43352 char argbuf[32] = {0};
43353 if(mindig)
43354 sprintf(argbuf, mindigbuf, arg);
43355 else zc_itoa(arg, argbuf);
43356
43357 ret = argbuf;
43358 return ret.c_str();
43359 }
43360 //
43361 case 's':
43362 {
43363
1/2
✓ Branch 0 taken 758 times.
✗ Branch 1 not taken.
758 if(mindig)
43364 Z_scripterrlog("Cannot use minimum digits flag for '%%s'\n");
43365
1/2
✓ Branch 0 taken 758 times.
✗ Branch 1 not taken.
758 if(arg)
43366 {
43367 758 int32_t strptr = (arg / 10000);
43368 758 ArrayManager am(strptr);
43369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 758 times.
758 if(am.invalid())
43370 ret = "<INVALID STRING>";
43371 758 else ArrayH::getString(strptr, ret, MAX_ZC_ARRAY_SIZE);
43372 758 }
43373 else ret = "<NULL>";
43374 758 return ret.c_str();
43375 }
43376 case 'c':
43377 {
43378 if(mindig)
43379 Z_scripterrlog("Cannot use minimum digits flag for '%%c'\n");
43380 int32_t c = (arg / 10000);
43381 if ( (char(c)) != c )
43382 {
43383 Z_scripterrlog("Illegal char value (%d) passed to sprintf as '%%c' arg\n", c);
43384 Z_scripterrlog("Value of invalid char will overflow.\n");
43385 }
43386 ret.push_back(char(c));
43387 return ret.c_str();
43388 }
43389 //
43390 case 'X':
43391 tempbool = true;
43392 [[fallthrough]];
43393 case 'x':
43394 {
43395 char argbuf[32] = {0};
43396 if(mindig)
43397 sprintf(argbuf,mindigbuf,arg / 10000);
43398 else zc_itoa( (arg/10000), argbuf, 16 ); //base 16; hex
43399
43400 for ( int32_t inx = 0; inx < 16; ++inx ) //set chosen caps
43401 {
43402 argbuf[inx] = ( tempbool ? toupper(argbuf[inx]) : tolower(argbuf[inx]) );
43403 }
43404 ret = "0x";
43405 ret += argbuf;
43406 return ret.c_str();
43407 }
43408 //
43409 case 'b': //int binary
43410 arg /= 10000;
43411 [[fallthrough]];
43412 case 'B': //long binary
43413 {
43414 char argbuf[33] = {0};
43415 int num_digits = mindig;
43416 for(int q = num_digits; q < 32; ++q)
43417 if(arg&(1<<q))
43418 num_digits = q+1;
43419 for(int q = 0; q < num_digits; ++q)
43420 {
43421 argbuf[q] = (arg&(1<<(num_digits-q-1)))
43422 ? '1' : '0';
43423 }
43424 ret = argbuf;
43425 return ret.c_str();
43426 }
43427 case 'a': //array
43428 {
43429 if(arg)
43430 {
43431 if(!is_valid_format(format[1]))
43432 {
43433 Z_scripterrlog("Format '%%a%c' is invalid!\n",format[1]);
43434 break;
43435 }
43436 ArrayManager am(arg/10000);
43437 ret = am.asString([&](int32_t val)
43438 {
43439 return zs_formatter(format+1, val, mindig);
43440 }, 214748);
43441 }
43442 else ret = "{ NULL }";
43443 return ret.c_str();
43444 }
43445 default:
43446 {
43447 Z_scripterrlog("Error: '%%%c' is not a valid printf argument.\n",format[0]);
43448 return ret.c_str();
43449 }
43450 }
43451 }
43452 Z_scripterrlog("Error: No format parameter given for zs_formatter\n");
43453 return ret.c_str();
43454 18980 }
43455
43456 10492 string zs_sprintf(char const* format, int32_t num_args, const bool varg)
43457 {
43458 10492 int32_t arg_offset = ((ri->sp + num_args) - 1);
43459 10492 int32_t next_arg = 0;
43460 10492 bool is_old_args = get_qr(qr_OLD_PRINTF_ARGS);
43461 10492 ostringstream oss;
43462
2/2
✓ Branch 0 taken 6856 times.
✓ Branch 1 taken 22616 times.
29472 while(format[0] != '\0')
43463 {
43464 22616 int32_t arg_val = 0;
43465
2/2
✓ Branch 0 taken 3636 times.
✓ Branch 1 taken 18980 times.
22616 if(next_arg < num_args)
43466 {
43467
2/2
✓ Branch 0 taken 5379 times.
✓ Branch 1 taken 13601 times.
18980 if(varg)
43468
1/2
✓ Branch 0 taken 5379 times.
✗ Branch 1 not taken.
5379 arg_val = zs_vargs.at(next_arg);
43469 else
43470
1/2
✓ Branch 0 taken 13601 times.
✗ Branch 1 not taken.
13601 arg_val = SH::read_stack(arg_offset - next_arg);
43471 18980 }
43472 22616 char buf[256] = {0};
43473
2/2
✓ Branch 0 taken 18980 times.
✓ Branch 1 taken 76611 times.
95591 for ( int32_t q = 0; q < 256; ++q )
43474 {
43475
2/2
✓ Branch 0 taken 3636 times.
✓ Branch 1 taken 72975 times.
76611 if(format[0] == '\0') //done
43476 {
43477
1/2
✓ Branch 0 taken 3636 times.
✗ Branch 1 not taken.
3636 oss << buf;
43478
1/2
✓ Branch 0 taken 3636 times.
✗ Branch 1 not taken.
3636 return oss.str();
43479 }
43480
2/2
✓ Branch 0 taken 19295 times.
✓ Branch 1 taken 53680 times.
72975 else if(format[0] == '%')
43481 {
43482 19295 ++format;
43483 19295 int32_t min_digits = 0;
43484
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 19295 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
19295 if(format[0] == '0' && !is_old_args)
43485 {
43486 char argbuf[4] = {0};
43487 int32_t q = 0;
43488 while(q < 4)
43489 {
43490 ++format;
43491 char c = format[0];
43492 if(c == '\0')
43493 {
43494 Z_scripterrlog("Cannot use minimum digits flag with no argument\n");
43495 oss << buf;
43496 return oss.str();
43497 }
43498 if(c >= '0' && c <= '9')
43499 argbuf[q++] = c;
43500 else
43501 {
43502 --format;
43503 break;
43504 }
43505 }
43506 ++format;
43507 min_digits = atoi(argbuf);
43508 if(!min_digits)
43509 {
43510 Z_scripterrlog("Error formatting string: Invalid number '%s'\n", argbuf);
43511 }
43512 }
43513
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19295 times.
19295 bool bin = (format[0] == 'b' || format[0] == 'B');
43514
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19295 times.
19295 bool hex = (format[0] == 'x' || format[0] == 'X');
43515
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19295 times.
19295 if(bin)
43516 {
43517 if(min_digits > 32)
43518 {
43519 Z_scripterrlog("Min digits argument cannot be larger than 32!"
43520 " Value will be truncated to 32.");
43521 min_digits = 32;
43522 }
43523 }
43524
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19295 times.
19295 else if(min_digits > 10)
43525 {
43526 Z_scripterrlog("Min digits argument cannot be larger than 10!"
43527 " Value will be truncated to 10.");
43528 min_digits = 10;
43529 }
43530 19295 char mindigbuf[15] = {0};
43531
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19295 times.
19295 sprintf(mindigbuf, "%%0%d%c", min_digits, hex ? format[0] : 'd');
43532 19295 bool tempbool = false;
43533
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18980 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 315 times.
19295 switch( format[0] )
43534 {
43535 case 'd':
43536 case 'f':
43537 case 'i': case 'p':
43538 case 'l':
43539 case 's':
43540 case 'c':
43541 case 'x': case 'X':
43542 case 'b': case 'B':
43543 {
43544 18980 ++next_arg;
43545
3/6
✓ Branch 0 taken 18980 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18980 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 18980 times.
✗ Branch 5 not taken.
18980 oss << buf << zs_formatter(format,arg_val,min_digits);
43546 18980 q = 300; //break main loop
43547 18980 break;
43548 }
43549 case 'a': //array print
43550 {
43551 ++next_arg;
43552 oss << buf << zs_formatter(format,arg_val,min_digits);
43553 while(format[0] == 'a')
43554 {
43555 if(is_valid_format(format[1]))
43556 ++format;
43557 else break;
43558 }
43559 q = 300; //break main loop
43560 break;
43561 }
43562 case '%':
43563 {
43564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 315 times.
315 if(min_digits)
43565 Z_scripterrlog("Cannot use minimum digits flag for '%%%%'\n");
43566 315 buf[q] = '%';
43567 315 break;
43568 }
43569 default:
43570 {
43571 if(is_old_args)
43572 buf[q] = format[0];
43573 else
43574 {
43575 Z_scripterrlog("Error: '%%%c' is not a valid printf argument.\n",format[0]);
43576 }
43577 break;
43578 }
43579 }
43580 19295 ++format;
43581 19295 }
43582 else
43583 {
43584 53680 buf[q] = format[0];
43585 53680 ++format;
43586 }
43587
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72975 times.
72975 if(q == 255)
43588 {
43589 oss << buf;
43590 break;
43591 }
43592 72975 }
43593 }
43594
1/2
✓ Branch 0 taken 6856 times.
✗ Branch 1 not taken.
6856 return oss.str();
43595 10492 }
43596
43597 3609 void FFScript::do_printf(const bool v, const bool varg)
43598 {
43599 int32_t num_args, format_arrayptr;
43600
2/2
✓ Branch 0 taken 3322 times.
✓ Branch 1 taken 287 times.
3609 if(varg)
43601 {
43602 3322 num_args = zs_vargs.size();
43603 3322 format_arrayptr = SH::read_stack(ri->sp) / 10000;
43604 3322 }
43605 else
43606 {
43607 287 num_args = SH::get_arg(sarg1, v) / 10000;
43608 287 format_arrayptr = SH::read_stack(ri->sp + num_args) / 10000;
43609 }
43610 3609 string formatstr;
43611
1/2
✓ Branch 0 taken 3609 times.
✗ Branch 1 not taken.
3609 ArrayH::getString(format_arrayptr, formatstr, MAX_ZC_ARRAY_SIZE);
43612
43613
2/4
✓ Branch 0 taken 3609 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3609 times.
3609 traceStr(zs_sprintf(formatstr.c_str(), num_args, varg));
43614
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 3322 times.
3609 if(varg) zs_vargs.clear();
43615 3609 }
43616 6883 void FFScript::do_sprintf(const bool v, const bool varg)
43617 {
43618 int32_t num_args, dest_arrayptr, format_arrayptr;
43619
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6883 times.
6883 if(varg)
43620 {
43621 num_args = zs_vargs.size();
43622 dest_arrayptr = SH::read_stack(ri->sp + 1) / 10000;
43623 format_arrayptr = SH::read_stack(ri->sp) / 10000;
43624 }
43625 else
43626 {
43627 6883 num_args = SH::get_arg(sarg1, v) / 10000;
43628 6883 dest_arrayptr = SH::read_stack(ri->sp + num_args + 1) / 10000;
43629 6883 format_arrayptr = SH::read_stack(ri->sp + num_args) / 10000;
43630 }
43631 6883 string formatstr;
43632
1/2
✓ Branch 0 taken 6883 times.
✗ Branch 1 not taken.
6883 ArrayH::getString(format_arrayptr, formatstr, MAX_ZC_ARRAY_SIZE);
43633
43634
1/2
✓ Branch 0 taken 6883 times.
✗ Branch 1 not taken.
6883 string output = zs_sprintf(formatstr.c_str(), num_args, varg);
43635
2/4
✓ Branch 0 taken 6883 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6883 times.
6883 if(ArrayH::setArray(dest_arrayptr, output) == SH::_Overflow)
43636 {
43637 Z_scripterrlog("Dest string supplied to 'sprintf()' not large enough\n");
43638 ri->d[rEXP1] = ArrayH::strlen(dest_arrayptr);
43639 }
43640 6883 else ri->d[rEXP1] = output.size();
43641
1/2
✓ Branch 0 taken 6883 times.
✗ Branch 1 not taken.
6883 if(varg) zs_vargs.clear();
43642 6883 }
43643 25969 void FFScript::do_varg_max()
43644 {
43645 25969 int32_t num_args = zs_vargs.size();
43646 25969 int32_t val = 0;
43647
1/2
✓ Branch 0 taken 25969 times.
✗ Branch 1 not taken.
25969 if (num_args > 0)
43648 25969 val = zs_vargs.at(0);
43649
2/2
✓ Branch 0 taken 25969 times.
✓ Branch 1 taken 25969 times.
51938 for(auto q = 1; q < num_args; ++q)
43650 {
43651 25969 int32_t tval = zs_vargs.at(q);
43652
2/2
✓ Branch 0 taken 7998 times.
✓ Branch 1 taken 17971 times.
25969 if(tval > val) val = tval;
43653 25969 }
43654 25969 zs_vargs.clear();
43655 25969 ri->d[rEXP1] = val;
43656 25969 }
43657 71 void FFScript::do_varg_min()
43658 {
43659 71 int32_t num_args = zs_vargs.size();
43660 71 int32_t val = 0;
43661
1/2
✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
71 if (num_args > 0)
43662 71 val = zs_vargs.at(0);
43663
2/2
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 71 times.
142 for(auto q = 1; q < num_args; ++q)
43664 {
43665 71 int32_t tval = zs_vargs.at(q);
43666
1/2
✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
71 if(tval < val) val = tval;
43667 71 }
43668 71 zs_vargs.clear();
43669 71 ri->d[rEXP1] = val;
43670 71 }
43671 void FFScript::do_varg_choose()
43672 {
43673 int32_t num_args = zs_vargs.size();
43674 int32_t val = 0;
43675 if(num_args > 0)
43676 {
43677 int32_t choice = zc_rand(num_args-1);
43678 val = zs_vargs.at(choice);
43679 }
43680 zs_vargs.clear();
43681 ri->d[rEXP1] = val;
43682 }
43683
43684 void FFScript::do_breakpoint()
43685 {
43686 int32_t arrayptr = get_register(sarg1) / 10000;
43687 string str;
43688 if(arrayptr && sarg1 != NUL)
43689 {
43690 ArrayH::getString(arrayptr, str, 512);
43691 str = "Breakpoint: " + str + "\n";
43692 }
43693 else str = "Breakpoint\n";
43694 TraceScriptIDs();
43695 al_trace("%s", str.c_str());
43696
43697 if ( zscript_debugger )
43698 {
43699 zscript_coloured_console.safeprint((CConsoleLoggerEx::COLOR_RED |
43700 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK),str.c_str());
43701 }
43702 if( zasm_debugger )
43703 {
43704 FFCore.zasm_break_mode = ZASM_BREAK_HALT; //Halt ZASM debugger; break execution
43705 coloured_console.safeprint((CConsoleLoggerEx::COLOR_RED |
43706 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK),str.c_str());
43707 }
43708 }
43709
43710 void FFScript::do_tracenl()
43711 {
43712 safe_al_trace("\n");
43713
43714 if ( zscript_debugger )
43715 {
43716 zscript_coloured_console.safeprint((CConsoleLoggerEx::COLOR_WHITE |
43717 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK),"\n");
43718 }
43719 }
43720
43721
43722 36948 void FFScript::TraceScriptIDs(bool zasm_console)
43723 {
43724 if(DEVTIMESTAMP)
43725 {
43726 if(!zasm_debugger && zasm_console) return;
43727 CConsoleLoggerEx console = (zasm_console ? coloured_console : zscript_coloured_console);
43728 bool cond = (zasm_console ? zasm_debugger : zscript_debugger);
43729
43730 char buf[256] = {0};
43731 //Calculate timestamp
43732 struct tm * tm_struct;
43733 time_t sysRTC;
43734 time (&sysRTC);
43735 tm_struct = localtime (&sysRTC);
43736
43737 sprintf(buf, "[%d:%d:%d] ", tm_struct->tm_hour, tm_struct->tm_min, tm_struct->tm_sec);
43738 //
43739
43740 al_trace("%s", buf);
43741 if ( cond ) {console.safeprint((CConsoleLoggerEx::COLOR_GREEN | CConsoleLoggerEx::COLOR_INTENSITY |
43742 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK),buf); }
43743 }
43744
2/2
✓ Branch 0 taken 33593 times.
✓ Branch 1 taken 3355 times.
36948 if(get_qr(qr_TRACESCRIPTIDS) || DEVLOGGING )
43745 {
43746
2/4
✓ Branch 0 taken 3355 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3355 times.
✗ Branch 3 not taken.
3355 if(!zasm_debugger && zasm_console) return;
43747
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3355 times.
3355 CConsoleLoggerEx console = (zasm_console ? coloured_console : zscript_coloured_console);
43748
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3355 times.
3355 bool cond = (zasm_console ? zasm_debugger : zscript_debugger);
43749 3355 char buf[256] = {0};
43750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3355 times.
3355 if(script_funcrun)
43751 {
43752 sprintf(buf, "Destructor(%d,%s): ", ri->thiskey, destructstr?destructstr->c_str():"UNKNOWN");
43753 }
43754
2/17
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1297 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 2058 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
3355 else switch(curScriptType)
43755 {
43756 case ScriptType::Global:
43757 {
43758 switch(curScriptNum)
43759 {
43760 case GLOBAL_SCRIPT_INIT:
43761 sprintf(buf, "Global Init(%s): ", globalmap[curScriptNum].scriptname.c_str());
43762 break;
43763 case GLOBAL_SCRIPT_GAME:
43764 sprintf(buf, "Global Active(%s): ", globalmap[curScriptNum].scriptname.c_str());
43765 break;
43766 case GLOBAL_SCRIPT_END:
43767 sprintf(buf, "Global Exit(%s): ", globalmap[curScriptNum].scriptname.c_str());
43768 break;
43769 case GLOBAL_SCRIPT_ONSAVELOAD:
43770 sprintf(buf, "Global SaveLoad(%s): ", globalmap[curScriptNum].scriptname.c_str());
43771 break;
43772 case GLOBAL_SCRIPT_ONLAUNCH:
43773 sprintf(buf, "Global Launch(%s): ", globalmap[curScriptNum].scriptname.c_str());
43774 break;
43775 case GLOBAL_SCRIPT_ONCONTGAME:
43776 sprintf(buf, "Global ContGame(%s): ", globalmap[curScriptNum].scriptname.c_str());
43777 break;
43778 case GLOBAL_SCRIPT_F6:
43779 sprintf(buf, "Global F6Menu(%s): ", globalmap[curScriptNum].scriptname.c_str());
43780 break;
43781 case GLOBAL_SCRIPT_ONSAVE:
43782 sprintf(buf, "Global Save(%s): ", globalmap[curScriptNum].scriptname.c_str());
43783 break;
43784 }
43785 break;
43786 }
43787
43788 case ScriptType::Player:
43789 {
43790 switch(curScriptNum)
43791 {
43792 case SCRIPT_PLAYER_INIT:
43793 sprintf(buf, "Player Init(%s): ", playermap[curScriptNum-1].scriptname.c_str());
43794 break;
43795 case SCRIPT_PLAYER_ACTIVE:
43796 sprintf(buf, "Player Active(%s): ", playermap[curScriptNum-1].scriptname.c_str());
43797 break;
43798 case SCRIPT_PLAYER_DEATH:
43799 sprintf(buf, "Player Death(%s): ", playermap[curScriptNum-1].scriptname.c_str());
43800 break;
43801 case SCRIPT_PLAYER_WIN:
43802 sprintf(buf, "Player Win(%s): ", playermap[curScriptNum-1].scriptname.c_str());
43803 break;
43804 }
43805 break;
43806 }
43807
43808 case ScriptType::Lwpn:
43809 sprintf(buf, "LWeapon(%u, %s): ", curScriptNum,lwpnmap[curScriptNum-1].scriptname.c_str());
43810 break;
43811
43812 case ScriptType::Ewpn:
43813 sprintf(buf, "EWeapon(%u, %s): ", curScriptNum,ewpnmap[curScriptNum-1].scriptname.c_str());
43814 break;
43815
43816 case ScriptType::NPC:
43817 sprintf(buf, "NPC(%u, %s): ", curScriptNum,npcmap[curScriptNum-1].scriptname.c_str());
43818 break;
43819
43820 case ScriptType::FFC:
43821
1/2
✓ Branch 0 taken 1297 times.
✗ Branch 1 not taken.
1297 sprintf(buf, "FFC(%u, %s): ", curScriptNum,ffcmap[curScriptNum-1].scriptname.c_str());
43822 1297 break;
43823
43824 case ScriptType::Item:
43825 sprintf(buf, "Item(%u, %s): ", curScriptNum,itemmap[curScriptNum-1].scriptname.c_str());
43826 break;
43827
43828 case ScriptType::OnMap:
43829 sprintf(buf, "DMapMap(%u, %s): ", curScriptNum,dmapmap[curScriptNum-1].scriptname.c_str());
43830 break;
43831 case ScriptType::ActiveSubscreen:
43832 sprintf(buf, "DMapASub(%u, %s): ", curScriptNum,dmapmap[curScriptNum-1].scriptname.c_str());
43833 break;
43834 case ScriptType::PassiveSubscreen:
43835 sprintf(buf, "DMapPSub(%u, %s): ", curScriptNum,dmapmap[curScriptNum-1].scriptname.c_str());
43836 break;
43837 case ScriptType::DMap:
43838
1/2
✓ Branch 0 taken 2058 times.
✗ Branch 1 not taken.
2058 sprintf(buf, "DMap(%u, %s): ", curScriptNum,dmapmap[curScriptNum-1].scriptname.c_str());
43839 2058 break;
43840
43841 case ScriptType::ItemSprite:
43842 sprintf(buf, "ItemSprite(%u, %s): ", curScriptNum,itemspritemap[curScriptNum-1].scriptname.c_str());
43843 break;
43844
43845 case ScriptType::Screen:
43846 sprintf(buf, "Screen(%u, %s): ", curScriptNum,screenmap[curScriptNum-1].scriptname.c_str());
43847 break;
43848
43849 case ScriptType::Combo:
43850 sprintf(buf, "Combo(%u, %s): ", curScriptNum,comboscriptmap[curScriptNum-1].scriptname.c_str());
43851 break;
43852
43853 case ScriptType::Generic:
43854 sprintf(buf, "Generic(%u, %s): ", curScriptNum,genericmap[curScriptNum-1].scriptname.c_str());
43855 break;
43856
43857 case ScriptType::GenericFrozen:
43858 sprintf(buf, "GenericFRZ(%u, %s): ", curScriptNum,genericmap[curScriptNum-1].scriptname.c_str());
43859 break;
43860 }
43861
43862
1/2
✓ Branch 0 taken 3355 times.
✗ Branch 1 not taken.
3355 al_trace("%s", buf);
43863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3355 times.
3355 if ( cond )
43864 console.safeprint((CConsoleLoggerEx::COLOR_GREEN|CConsoleLoggerEx::COLOR_INTENSITY|
43865 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK),buf);
43866 3355 }
43867 36948 }
43868
43869 2 void FFScript::do_cleartrace()
43870 {
43871 2 zc_trace_clear();
43872 2 clearConsole();
43873 2 }
43874
43875 1 string inttobase(word base, int32_t x, word mindigits)
43876 {
43877 static const char coeff[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
43878
43879 1 string s2;
43880
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 word digits = zc_max(mindigits - 1, word(floor(log(double(x)) / log(double(base)))));
43881
43882
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 for(int32_t i = digits; i >= 0; i--)
43883 {
43884
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 s2 += coeff[word(floor(x / pow(double(base), i))) % base];
43885 1 }
43886
43887 1 return s2;
43888
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 }
43889
43890 1 void FFScript::do_tracetobase()
43891 {
43892 1 int32_t x = SH::read_stack(ri->sp + 2) / 10000;
43893 1 uint32_t base = vbound(SH::read_stack(ri->sp + 1) / 10000, 2, 36);
43894
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 uint32_t mindigits = zc_max(1, SH::read_stack(ri->sp) / 10000);
43895
43896
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 string s2 = x < 0 ? "-": "";
43897
43898
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
1 switch(base)
43899 {
43900 case 8:
43901 s2 += '0';
43902 break;
43903
43904 case 16:
43905 s2 += "0x";
43906 break;
43907 }
43908
43909
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 s2 += inttobase(base, int32_t(fabs(double(x))), mindigits);
43910
43911
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
1 switch(base)
43912 {
43913 case 8:
43914 case 10:
43915 case 16:
43916 1 break;
43917
43918 case 2:
43919 s2 += 'b';
43920 break;
43921
43922 default:
43923 std::stringstream ss;
43924 ss << " (Base " << base << ')';
43925 s2 += ss.str();
43926 break;
43927 }
43928
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 TraceScriptIDs();
43929
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 s2 += "\n";
43930
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 al_trace("%s", s2.c_str());
43931
43932
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( zscript_debugger )
43933 {
43934 zscript_coloured_console.safeprint((CConsoleLoggerEx::COLOR_WHITE |
43935 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK),s2.c_str());
43936 }
43937 1 }
43938
43939 //SRAM Functions
43940 void FFScript::write_dmaps(PACKFILE *f, int32_t vers_id)
43941 {
43942 word dmap_count=count_dmaps();
43943
43944 dmap_count=zc_min(dmap_count, 512);
43945 dmap_count=zc_min(dmap_count, MAXDMAPS-0);
43946
43947 //finally... section data
43948 if(!p_iputw(dmap_count,f))
43949 {
43950 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",5);
43951 }
43952
43953
43954 for(int32_t i=0; i<dmap_count; i++)
43955 {
43956 if(!p_putc(DMaps[i].map,f))
43957 {
43958 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",6);
43959 }
43960
43961 if(!p_iputw(DMaps[i].level,f))
43962 {
43963 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",7);
43964 }
43965
43966 if(!p_putc(DMaps[i].xoff,f))
43967 {
43968 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",8);
43969 }
43970
43971 if(!p_putc(DMaps[i].compass,f))
43972 {
43973 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",9);
43974 }
43975
43976 if(!p_iputw(DMaps[i].color,f))
43977 {
43978 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",10);
43979 }
43980
43981 if(!p_putc(DMaps[i].midi,f))
43982 {
43983 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",11);
43984 }
43985
43986 if(!p_putc(DMaps[i].cont,f))
43987 {
43988 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",12);
43989 }
43990
43991 if(!p_putc(DMaps[i].type,f))
43992 {
43993 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",13);
43994 }
43995
43996 for(int32_t j=0; j<8; j++)
43997 {
43998 if(!p_putc(DMaps[i].grid[j],f))
43999 {
44000 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",14);
44001 }
44002 }
44003
44004 //16
44005 if(!pfwrite(&DMaps[i].name,sizeof(DMaps[0].name),f))
44006 {
44007 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",15);
44008 }
44009
44010 if(!pfwrite(&DMaps[i].title,sizeof(DMaps[0].title),f))
44011 {
44012 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",16);
44013 }
44014
44015 if(!pfwrite(&DMaps[i].intro,sizeof(DMaps[0].intro),f))
44016 {
44017 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",17);
44018 }
44019
44020 if(!p_iputl(DMaps[i].minimap_1_tile,f))
44021 {
44022 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",18);
44023 }
44024
44025 if(!p_putc(DMaps[i].minimap_1_cset,f))
44026 {
44027 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",19);
44028 }
44029
44030 if(!p_iputl(DMaps[i].minimap_2_tile,f))
44031 {
44032 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",20);
44033 }
44034
44035 if(!p_putc(DMaps[i].minimap_2_cset,f))
44036 {
44037 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",21);
44038 }
44039
44040 if(!p_iputl(DMaps[i].largemap_1_tile,f))
44041 {
44042 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",22);
44043 }
44044
44045 if(!p_putc(DMaps[i].largemap_1_cset,f))
44046 {
44047 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",23);
44048 }
44049
44050 if(!p_iputl(DMaps[i].largemap_2_tile,f))
44051 {
44052 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",24);
44053 }
44054
44055 if(!p_putc(DMaps[i].largemap_2_cset,f))
44056 {
44057 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",25);
44058 }
44059
44060 if(!pfwrite(&DMaps[i].tmusic,sizeof(DMaps[0].tmusic),f))
44061 {
44062 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",26);
44063 }
44064
44065 if(!p_putc(DMaps[i].tmusictrack,f))
44066 {
44067 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",25);
44068 }
44069
44070 if(!p_putc(DMaps[i].active_subscreen,f))
44071 {
44072 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",26);
44073 }
44074
44075 if(!p_putc(DMaps[i].passive_subscreen,f))
44076 {
44077 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",27);
44078 }
44079
44080 byte disabled[32];
44081 memset(disabled,0,32);
44082
44083 for(int32_t j=0; j<MAXITEMS; j++)
44084 {
44085 if(DMaps[i].disableditems[j])
44086 {
44087 disabled[j/8] |= (1 << (j%8));
44088 }
44089 }
44090
44091 if(!pfwrite(disabled,32,f))
44092 {
44093 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",28);
44094 }
44095
44096 if(!p_iputl(DMaps[i].flags,f))
44097 {
44098 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",29);
44099 }
44100 if(!p_putc(DMaps[i].sideview,f))
44101 {
44102 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",30);
44103 }
44104 if(!p_iputw(DMaps[i].script,f))
44105 {
44106 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",31);
44107 }
44108 for ( int32_t q = 0; q < 8; q++ )
44109 {
44110 if(!p_iputl(DMaps[i].initD[q],f))
44111 {
44112 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",32);
44113 }
44114
44115 }
44116 for ( int32_t q = 0; q < 8; q++ )
44117 {
44118 for ( int32_t w = 0; w < 65; w++ )
44119 {
44120 if (!p_putc(DMaps[i].initD_label[q][w],f))
44121 {
44122 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",33);
44123 }
44124 }
44125 }
44126 }
44127 }
44128 void FFScript::read_dmaps(PACKFILE *f, int32_t vers_id)
44129 {
44130 word dmap_count=count_dmaps();
44131
44132 dmap_count=zc_min(dmap_count, 512);
44133 dmap_count=zc_min(dmap_count, MAXDMAPS-0);
44134
44135 //finally... section data
44136 if(!p_igetw(&dmap_count,f))
44137 {
44138 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",5);
44139 }
44140
44141
44142 for(int32_t i=0; i<dmap_count; i++)
44143 {
44144 if(!p_getc(&DMaps[i].map,f))
44145 {
44146 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",6);
44147 }
44148
44149 if(!p_igetw(&DMaps[i].level,f))
44150 {
44151 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",7);
44152 }
44153
44154 if(!p_getc(&DMaps[i].xoff,f))
44155 {
44156 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",8);
44157 }
44158
44159 if(!p_getc(&DMaps[i].compass,f))
44160 {
44161 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",9);
44162 }
44163
44164 if(!p_igetw(&DMaps[i].color,f))
44165 {
44166 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",10);
44167 }
44168
44169 if(!p_getc(&DMaps[i].midi,f))
44170 {
44171 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",11);
44172 }
44173
44174 if(!p_getc(&DMaps[i].cont,f))
44175 {
44176 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",12);
44177 }
44178
44179 if(!p_getc(&DMaps[i].type,f))
44180 {
44181 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",13);
44182 }
44183
44184 for(int32_t j=0; j<8; j++)
44185 {
44186 if(!p_getc(&DMaps[i].grid[j],f))
44187 {
44188 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",14);
44189 }
44190 }
44191
44192 //16
44193 if(!pfread((&DMaps[i].name),sizeof(DMaps[0].name),f))
44194 {
44195 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",15);
44196 }
44197
44198 if(!pfread((&DMaps[i].title),sizeof(DMaps[0].title),f))
44199 {
44200 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",16);
44201 }
44202
44203 if(!pfread((&DMaps[i].intro),sizeof(DMaps[0].intro),f))
44204 {
44205 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",17);
44206 }
44207
44208 if(!p_igetl(&DMaps[i].minimap_1_tile,f))
44209 {
44210 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",18);
44211 }
44212
44213 if(!p_getc(&DMaps[i].minimap_1_cset,f))
44214 {
44215 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",19);
44216 }
44217
44218 if(!p_igetl(&DMaps[i].minimap_2_tile,f))
44219 {
44220 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",20);
44221 }
44222
44223 if(!p_getc(&DMaps[i].minimap_2_cset,f))
44224 {
44225 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",21);
44226 }
44227
44228 if(!p_igetl(&DMaps[i].largemap_1_tile,f))
44229 {
44230 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",22);
44231 }
44232
44233 if(!p_getc(&DMaps[i].largemap_1_cset,f))
44234 {
44235 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",23);
44236 }
44237
44238 if(!p_igetl(&DMaps[i].largemap_2_tile,f))
44239 {
44240 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",24);
44241 }
44242
44243 if(!p_getc(&DMaps[i].largemap_2_cset,f))
44244 {
44245 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",25);
44246 }
44247
44248 if(!pfread((&DMaps[i].tmusic),sizeof(DMaps[0].tmusic),f))
44249 {
44250 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",26);
44251 }
44252
44253 if(!p_getc(&DMaps[i].tmusictrack,f))
44254 {
44255 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",25);
44256 }
44257
44258 if(!p_getc(&DMaps[i].active_subscreen,f))
44259 {
44260 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",26);
44261 }
44262
44263 if(!p_getc(&DMaps[i].passive_subscreen,f))
44264 {
44265 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",27);
44266 }
44267
44268 byte disabled[32];
44269 memset(disabled,0,32);
44270
44271 for(int32_t j=0; j<MAXITEMS; j++)
44272 {
44273 if(&DMaps[i].disableditems[j])
44274 {
44275 disabled[j/8] |= (1 << (j%8));
44276 }
44277 }
44278
44279 if(!pfread(disabled,32,f))
44280 {
44281 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",28);
44282 }
44283
44284 if(!p_igetl(&DMaps[i].flags,f))
44285 {
44286 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",29);
44287 }
44288 if(!p_getc(&DMaps[i].sideview,f))
44289 {
44290 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",30);
44291 }
44292 if(!p_igetw(&DMaps[i].script,f))
44293 {
44294 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",31);
44295 }
44296 for ( int32_t q = 0; q < 8; q++ )
44297 {
44298 if(!p_igetl(&DMaps[i].initD[q],f))
44299 {
44300 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",32);
44301 }
44302
44303 }
44304 for ( int32_t q = 0; q < 8; q++ )
44305 {
44306 for ( int32_t w = 0; w < 65; w++ )
44307 {
44308 if (!p_getc(&DMaps[i].initD_label[q][w],f))
44309 {
44310 Z_scripterrlog("do_savegamestructs FAILED to read DMAP NODE: %d",33);
44311 }
44312 }
44313 }
44314 }
44315 }
44316
44317
44318
44319 void FFScript::read_combos(PACKFILE *f, int32_t version_id)
44320 {
44321
44322 word combos_used = 0;
44323
44324 if(!p_igetw(&combos_used,f))
44325 {
44326 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",5);
44327 }
44328
44329 for(int32_t i=0; i<combos_used; i++)
44330 {
44331 if(!p_igetl(&combobuf[i].tile,f))
44332 {
44333 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",6);
44334 }
44335
44336 if(!p_getc(&combobuf[i].flip,f))
44337 {
44338 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",7);
44339 }
44340
44341 if(!p_getc(&combobuf[i].walk,f))
44342 {
44343 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",8);
44344 }
44345
44346 if(!p_getc(&combobuf[i].type,f))
44347 {
44348 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",9);
44349 }
44350
44351 if(!p_getc(&combobuf[i].csets,f))
44352 {
44353 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",10);
44354 }
44355
44356 if(!p_getc(&combobuf[i].frames,f))
44357 {
44358 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",11);
44359 }
44360
44361 if(!p_getc(&combobuf[i].speed,f))
44362 {
44363 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",12);
44364 }
44365
44366 if(!p_igetw(&combobuf[i].nextcombo,f))
44367 {
44368 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",13);
44369 }
44370
44371 if(!p_getc(&combobuf[i].nextcset,f))
44372 {
44373 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",14);
44374 }
44375
44376 if(!p_getc(&combobuf[i].flag,f))
44377 {
44378 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",15);
44379 }
44380
44381 if(!p_getc(&combobuf[i].skipanim,f))
44382 {
44383 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",16);
44384 }
44385
44386 if(!p_igetw(&combobuf[i].nexttimer,f))
44387 {
44388 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",17);
44389 }
44390
44391 if(!p_getc(&combobuf[i].skipanimy,f))
44392 {
44393 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",18);
44394 }
44395
44396 if(!p_getc(&combobuf[i].animflags,f))
44397 {
44398 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",19);
44399 }
44400
44401 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
44402 {
44403 if(!p_igetl(&combobuf[i].attributes[q],f))
44404 {
44405 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",20);
44406 }
44407 }
44408 if(!p_igetl(&combobuf[i].usrflags,f))
44409 {
44410 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",21);
44411 }
44412 for ( int32_t q = 0; q < 6; q++ )
44413 {
44414 if(!p_igetl(&combobuf[i].triggerflags[q],f))
44415 {
44416 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",22);
44417 }
44418 }
44419
44420 if(!p_igetl(&combobuf[i].triggerlevel,f))
44421 {
44422 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",23);
44423 }
44424 for ( int32_t q = 0; q < 11; q++ )
44425 {
44426 if(!p_getc(&combobuf[i].label[q],f))
44427 {
44428 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",24);
44429 }
44430 }
44431 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
44432 {
44433 if(!p_getc(&combobuf[i].attribytes[q],f))
44434 {
44435 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",25);
44436 }
44437 }
44438 if(!p_igetw(&combobuf[i].script,f))
44439 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",26);
44440 for ( int32_t q = 0; q < 2; q++ )
44441 {
44442 if(!p_igetl(&combobuf[i].initd[q],f))
44443 {
44444 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",27);
44445 }
44446 }
44447 if(!p_igetl(&combobuf[i].o_tile,f))
44448 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",28);
44449 if(!p_getc(&combobuf[i].cur_frame,f))
44450 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",29);
44451 if(!p_getc(&combobuf[i].aclk,f))
44452 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",30);
44453 }
44454 }
44455
44456 void FFScript::write_combos(PACKFILE *f, int32_t version_id)
44457 {
44458
44459 word combos_used = 0;
44460
44461 //finally... section data
44462 combos_used=count_combos()-0;
44463 combos_used=zc_min(combos_used, MAXCOMBOS);
44464
44465 if(!p_iputw(combos_used,f))
44466 {
44467 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",5);
44468 }
44469
44470 for(int32_t i=0; i<combos_used; i++)
44471 {
44472 if(!p_iputl(combobuf[i].tile,f))
44473 {
44474 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",6);
44475 }
44476
44477 if(!p_putc(combobuf[i].flip,f))
44478 {
44479 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",7);
44480 }
44481
44482 if(!p_putc(combobuf[i].walk,f))
44483 {
44484 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",8);
44485 }
44486
44487 if(!p_putc(combobuf[i].type,f))
44488 {
44489 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",9);
44490 }
44491
44492 if(!p_putc(combobuf[i].csets,f))
44493 {
44494 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",10);
44495 }
44496
44497 if(!p_putc(combobuf[i].frames,f))
44498 {
44499 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",11);
44500 }
44501
44502 if(!p_putc(combobuf[i].speed,f))
44503 {
44504 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",12);
44505 }
44506
44507 if(!p_iputw(combobuf[i].nextcombo,f))
44508 {
44509 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",13);
44510 }
44511
44512 if(!p_putc(combobuf[i].nextcset,f))
44513 {
44514 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",14);
44515 }
44516
44517 if(!p_putc(combobuf[i].flag,f))
44518 {
44519 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",15);
44520 }
44521
44522 if(!p_putc(combobuf[i].skipanim,f))
44523 {
44524 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",16);
44525 }
44526
44527 if(!p_iputw(combobuf[i].nexttimer,f))
44528 {
44529 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",17);
44530 }
44531
44532 if(!p_putc(combobuf[i].skipanimy,f))
44533 {
44534 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",18);
44535 }
44536
44537 if(!p_putc(combobuf[i].animflags,f))
44538 {
44539 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",19);
44540 }
44541
44542 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
44543 {
44544 if(!p_iputl(combobuf[i].attributes[q],f))
44545 {
44546 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",20);
44547 }
44548 }
44549 if(!p_iputl(combobuf[i].usrflags,f))
44550 {
44551 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",21);
44552 }
44553 for ( int32_t q = 0; q < 6; q++ )
44554 {
44555 if(!p_iputl(combobuf[i].triggerflags[q],f))
44556 {
44557 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",22);
44558 }
44559 }
44560
44561 if(!p_iputl(combobuf[i].triggerlevel,f))
44562 {
44563 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",23);
44564 }
44565 for ( int32_t q = 0; q < 11; q++ )
44566 {
44567 if(!p_putc(combobuf[i].label[q],f))
44568 {
44569 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",24);
44570 }
44571 }
44572 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
44573 {
44574 if(!p_putc(combobuf[i].attribytes[q],f))
44575 {
44576 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",25);
44577 }
44578 }
44579 if(!p_iputw(combobuf[i].script,f))
44580 {
44581 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",26);
44582 }
44583 for ( int32_t q = 0; q < 2; q++ )
44584 {
44585 if(!p_iputl(combobuf[i].initd[q],f))
44586 {
44587 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",27);
44588 }
44589 }
44590 if(!p_iputl(combobuf[i].o_tile,f))
44591 {
44592 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",28);
44593 }
44594 if(!p_putc(combobuf[i].cur_frame,f))
44595 {
44596 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",29);
44597 }
44598 if(!p_putc(combobuf[i].aclk,f))
44599 {
44600 Z_scripterrlog("do_savegamestructs FAILED to read COMBO NODE: %d",30);
44601 }
44602
44603 }
44604 }
44605 void FFScript::read_weaponsprtites(PACKFILE *f, int32_t vers_id)
44606 {
44607 for(int32_t i=0; i<MAXWPNS; i++)
44608 {
44609 word oldtile = 0;
44610 if(!p_igetw(&oldtile,f))
44611 {
44612 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",6);
44613 }
44614
44615 if(!p_getc(&wpnsbuf[i].misc,f))
44616 {
44617 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",7);
44618 }
44619
44620 if(!p_getc(&wpnsbuf[i].csets,f))
44621 {
44622 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",8);
44623 }
44624
44625 if(!p_getc(&wpnsbuf[i].frames,f))
44626 {
44627 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",9);
44628 }
44629
44630 if(!p_getc(&wpnsbuf[i].speed,f))
44631 {
44632 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",10);
44633 }
44634
44635 if(!p_getc(&wpnsbuf[i].type,f))
44636 {
44637 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",11);
44638 }
44639
44640 if(!p_igetw(&wpnsbuf[i].script,f))
44641 {
44642 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",12);
44643 }
44644
44645 if(!p_igetl(&wpnsbuf[i].tile,f))
44646 {
44647 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",12);
44648 }
44649 }
44650 }
44651 void FFScript::write_weaponsprtites(PACKFILE *f, int32_t vers_id)
44652 {
44653 for(int32_t i=0; i<MAXWPNS; i++)
44654 {
44655 if(!p_iputw(wpnsbuf[i].tile,f))
44656 {
44657 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",6);
44658 }
44659
44660 if(!p_putc(wpnsbuf[i].misc,f))
44661 {
44662 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",7);
44663 }
44664
44665 if(!p_putc(wpnsbuf[i].csets,f))
44666 {
44667 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",8);
44668 }
44669
44670 if(!p_putc(wpnsbuf[i].frames,f))
44671 {
44672 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",9);
44673 }
44674
44675 if(!p_putc(wpnsbuf[i].speed,f))
44676 {
44677 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",10);
44678 }
44679
44680 if(!p_putc(wpnsbuf[i].type,f))
44681 {
44682 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",11);
44683 }
44684
44685 if(!p_iputw(wpnsbuf[i].script,f))
44686 {
44687 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",12);
44688 }
44689
44690 if(!p_iputl(wpnsbuf[i].tile,f))
44691 {
44692 Z_scripterrlog("do_savegamestructs FAILED to read WPNSPRITE NODE: %d",12);
44693 }
44694 }
44695 }
44696
44697
44698 void FFScript::read_enemies(PACKFILE *f, int32_t vers_id)
44699 {
44700 if ( !f ) return;
44701 for(int32_t i=0; i<MAXGUYS; i++)
44702 {
44703 if(!p_igetl(&guysbuf[i].flags,f))
44704 {
44705 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",6);
44706 }
44707
44708 if(!p_igetl(&guysbuf[i].flags2,f))
44709 {
44710 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",7);
44711 }
44712
44713 if(!p_igetl(&guysbuf[i].tile,f))
44714 {
44715 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",8);
44716 }
44717
44718 if(!p_getc(&guysbuf[i].width,f))
44719 {
44720 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",9);
44721 }
44722
44723 if(!p_getc(&guysbuf[i].height,f))
44724 {
44725 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",10);
44726 }
44727
44728 if(!p_igetl(&guysbuf[i].s_tile,f))
44729 {
44730 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",11);
44731 }
44732
44733 if(!p_getc(&guysbuf[i].s_width,f))
44734 {
44735 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",12);
44736 }
44737
44738 if(!p_getc(&guysbuf[i].s_height,f))
44739 {
44740 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",13);
44741 }
44742
44743 if(!p_igetl(&guysbuf[i].e_tile,f))
44744 {
44745 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",14);
44746 }
44747
44748 if(!p_getc(&guysbuf[i].e_width,f))
44749 {
44750 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",15);
44751 }
44752
44753 if(!p_getc(&guysbuf[i].e_height,f))
44754 {
44755 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",16);
44756 }
44757
44758 if(!p_igetw(&guysbuf[i].hp,f))
44759 {
44760 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",17);
44761 }
44762
44763 if(!p_igetw(&guysbuf[i].family,f))
44764 {
44765 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",18);
44766 }
44767
44768 if(!p_igetw(&guysbuf[i].cset,f))
44769 {
44770 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",19);
44771 }
44772
44773 if(!p_igetw(&guysbuf[i].anim,f))
44774 {
44775 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",20);
44776 }
44777
44778 if(!p_igetw(&guysbuf[i].e_anim,f))
44779 {
44780 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",21);
44781 }
44782
44783 if(!p_igetw(&guysbuf[i].frate,f))
44784 {
44785 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",22);
44786 }
44787
44788 if(!p_igetw(&guysbuf[i].e_frate,f))
44789 {
44790 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",23);
44791 }
44792
44793 if(!p_igetw(&guysbuf[i].dp,f))
44794 {
44795 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",24);
44796 }
44797
44798 if(!p_igetw(&guysbuf[i].wdp,f))
44799 {
44800 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",25);
44801 }
44802
44803 if(!p_igetw(&guysbuf[i].weapon,f))
44804 {
44805 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",26);
44806 }
44807
44808 if(!p_igetw(&guysbuf[i].rate,f))
44809 {
44810 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",27);
44811 }
44812
44813 if(!p_igetw(&guysbuf[i].hrate,f))
44814 {
44815 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",28);
44816 }
44817
44818 if(!p_igetw(&guysbuf[i].step,f))
44819 {
44820 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",29);
44821 }
44822
44823 if(!p_igetw(&guysbuf[i].homing,f))
44824 {
44825 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",30);
44826 }
44827
44828 if(!p_igetw(&guysbuf[i].grumble,f))
44829 {
44830 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",31);
44831 }
44832
44833 if(!p_igetw(&guysbuf[i].item_set,f))
44834 {
44835 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",32);
44836 }
44837
44838 if(!p_igetl(&guysbuf[i].misc1,f))
44839 {
44840 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",33);
44841 }
44842
44843 if(!p_igetl(&guysbuf[i].misc2,f))
44844 {
44845 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",34);
44846 }
44847
44848 if(!p_igetl(&guysbuf[i].misc3,f))
44849 {
44850 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",35);
44851 }
44852
44853 if(!p_igetl(&guysbuf[i].misc4,f))
44854 {
44855 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",36);
44856 }
44857
44858 if(!p_igetl(&guysbuf[i].misc5,f))
44859 {
44860 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",37);
44861 }
44862
44863 if(!p_igetl(&guysbuf[i].misc6,f))
44864 {
44865 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",38);
44866 }
44867
44868 if(!p_igetl(&guysbuf[i].misc7,f))
44869 {
44870 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",39);
44871 }
44872
44873 if(!p_igetl(&guysbuf[i].misc8,f))
44874 {
44875 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",40);
44876 }
44877
44878 if(!p_igetl(&guysbuf[i].misc9,f))
44879 {
44880 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",41);
44881 }
44882
44883 if(!p_igetl(&guysbuf[i].misc10,f))
44884 {
44885 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",42);
44886 }
44887
44888 if(!p_igetw(&guysbuf[i].bgsfx,f))
44889 {
44890 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",43);
44891 }
44892
44893 if(!p_igetw(&guysbuf[i].bosspal,f))
44894 {
44895 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",44);
44896 }
44897
44898 if(!p_igetw(&guysbuf[i].extend,f))
44899 {
44900 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",45);
44901 }
44902
44903 for(int32_t j=0; j < edefLAST; j++)
44904 {
44905 if(!p_getc(&guysbuf[i].defense[j],f))
44906 {
44907 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",46);
44908 }
44909 }
44910
44911 if(!p_getc(&guysbuf[i].hitsfx,f))
44912 {
44913 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",47);
44914 }
44915
44916 if(!p_getc(&guysbuf[i].deadsfx,f))
44917 {
44918 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",48);
44919 }
44920
44921 if(!p_igetl(&guysbuf[i].misc11,f))
44922 {
44923 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",49);
44924 }
44925
44926 if(!p_igetl(&guysbuf[i].misc12,f))
44927 {
44928 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",50);
44929 }
44930
44931 //New 2.6 defences
44932 for(int32_t j=edefLAST; j < edefLAST255; j++)
44933 {
44934 if(!p_getc(&guysbuf[i].defense[j],f))
44935 {
44936 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",51);
44937 }
44938 }
44939
44940 //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs
44941 if(!p_igetl(&guysbuf[i].txsz,f))
44942 {
44943 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",52);
44944 }
44945 if(!p_igetl(&guysbuf[i].tysz,f))
44946 {
44947 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",53);
44948 }
44949 if(!p_igetl(&guysbuf[i].hxsz,f))
44950 {
44951 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",54);
44952 }
44953 if(!p_igetl(&guysbuf[i].hysz,f))
44954 {
44955 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",55);
44956 }
44957 if(!p_igetl(&guysbuf[i].hzsz,f))
44958 {
44959 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",56);
44960 }
44961 // These are not fixed types, but ints, so they are safe to use here.
44962 if(!p_igetl(&guysbuf[i].hxofs,f))
44963 {
44964 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",57);
44965 }
44966 if(!p_igetl(&guysbuf[i].hyofs,f))
44967 {
44968 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",58);
44969 }
44970 if(!p_igetl(&guysbuf[i].xofs,f))
44971 {
44972 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",59);
44973 }
44974 if(!p_igetl(&guysbuf[i].yofs,f))
44975 {
44976 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",60);
44977 }
44978 if(!p_igetl(&guysbuf[i].zofs,f))
44979 {
44980 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",61);
44981 }
44982 if(!p_igetl(&guysbuf[i].wpnsprite,f))
44983 {
44984 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",62);
44985 }
44986 if(!p_igetl(&guysbuf[i].SIZEflags,f))
44987 {
44988 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",63);
44989 }
44990 if(!p_igetl(&guysbuf[i].frozentile,f))
44991 {
44992 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",64);
44993 }
44994 if(!p_igetl(&guysbuf[i].frozencset,f))
44995 {
44996 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",65);
44997 }
44998 if(!p_igetl(&guysbuf[i].frozenclock,f))
44999 {
45000 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",66);
45001 }
45002
45003 for ( int32_t q = 0; q < 10; q++ )
45004 {
45005 if(!p_igetw(&guysbuf[i].frozenmisc[q],f))
45006 {
45007 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",67);
45008 }
45009 }
45010 if(!p_igetw(&guysbuf[i].firesfx,f))
45011 {
45012 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",68);
45013 }
45014 //misc 16->31
45015 if(!p_igetl(&guysbuf[i].misc16,f))
45016 {
45017 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",69);
45018 }
45019 if(!p_igetl(&guysbuf[i].misc17,f))
45020 {
45021 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",70);
45022 }
45023 if(!p_igetl(&guysbuf[i].misc18,f))
45024 {
45025 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",71);
45026 }
45027 if(!p_igetl(&guysbuf[i].misc19,f))
45028 {
45029 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",72);
45030 }
45031 if(!p_igetl(&guysbuf[i].misc20,f))
45032 {
45033 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",73);
45034 }
45035 if(!p_igetl(&guysbuf[i].misc21,f))
45036 {
45037 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",74);
45038 }
45039 if(!p_igetl(&guysbuf[i].misc22,f))
45040 {
45041 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",75);
45042 }
45043 if(!p_igetl(&guysbuf[i].misc23,f))
45044 {
45045 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",76);
45046 }
45047 if(!p_igetl(&guysbuf[i].misc24,f))
45048 {
45049 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",77);
45050 }
45051 if(!p_igetl(&guysbuf[i].misc25,f))
45052 {
45053 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",78);
45054 }
45055 if(!p_igetl(&guysbuf[i].misc26,f))
45056 {
45057 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",79);
45058 }
45059 if(!p_igetl(&guysbuf[i].misc27,f))
45060 {
45061 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",80);
45062 }
45063 if(!p_igetl(&guysbuf[i].misc28,f))
45064 {
45065 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",81);
45066 }
45067 if(!p_igetl(&guysbuf[i].misc29,f))
45068 {
45069 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",82);
45070 }
45071 if(!p_igetl(&guysbuf[i].misc30,f))
45072 {
45073 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",83);
45074 }
45075 if(!p_igetl(&guysbuf[i].misc31,f))
45076 {
45077 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",84);
45078 }
45079 if(!p_igetl(&guysbuf[i].misc32,f))
45080 {
45081 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",85);
45082 }
45083 for ( int32_t q = 0; q < 32; q++ )
45084 {
45085 if(!p_igetl(&guysbuf[i].movement[q],f))
45086 {
45087 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",86);
45088 }
45089 }
45090 for ( int32_t q = 0; q < 32; q++ )
45091 {
45092 if(!p_igetl(&guysbuf[i].new_weapon[q],f))
45093 {
45094 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",87);
45095 }
45096 }
45097 if(!p_igetw(&guysbuf[i].script,f))
45098 {
45099 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",88);
45100 }
45101 for ( int32_t q = 0; q < 8; q++ )
45102 {
45103 if(!p_igetl(&guysbuf[i].initD[q],f))
45104 {
45105 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",89);
45106 }
45107 }
45108 for ( int32_t q = 0; q < 2; q++ )
45109 {
45110 if(!p_igetl(&guysbuf[i].initA[q],f))
45111 {
45112 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",90);
45113 }
45114 }
45115 if(!p_igetl(&guysbuf[i].editorflags,f))
45116 {
45117 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",91);
45118 }
45119 //somehow forgot these in the older builds -Z
45120 if(!p_igetl(&guysbuf[i].misc13,f))
45121 {
45122 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",92);
45123 }
45124 if(!p_igetl(&guysbuf[i].misc14,f))
45125 {
45126 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",93);
45127 }
45128 if(!p_igetl(&guysbuf[i].misc15,f))
45129 {
45130 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",94);
45131 }
45132
45133 //Enemy Editor InitD[] labels
45134 for ( int32_t q = 0; q < 8; q++ )
45135 {
45136 for ( int32_t w = 0; w < 65; w++ )
45137 {
45138 if(!p_getc(&guysbuf[i].initD_label[q][w],f))
45139 {
45140 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",95);
45141 }
45142 }
45143 for ( int32_t w = 0; w < 65; w++ )
45144 {
45145 if(!p_getc(&guysbuf[i].weapon_initD_label[q][w],f))
45146 {
45147 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",96);
45148 }
45149 }
45150 }
45151 if(!p_igetw(&guysbuf[i].weaponscript,f))
45152 {
45153 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",97);
45154 }
45155 //eweapon initD
45156 for ( int32_t q = 0; q < 8; q++ )
45157 {
45158 if(!p_igetl(&guysbuf[i].weap_initiald[q],f))
45159 {
45160 Z_scripterrlog("do_savegamestructs FAILED to read GUY NODE: %d",98);
45161 }
45162 }
45163
45164 }
45165 }
45166
45167 void FFScript::write_enemies(PACKFILE *f, int32_t vers_id)
45168 {
45169 if ( !f ) return;
45170 for(int32_t i=0; i<MAXGUYS; i++)
45171 {
45172 if(!p_iputl(guysbuf[i].flags,f))
45173 {
45174 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",6);
45175 }
45176
45177 if(!p_iputl(guysbuf[i].flags2,f))
45178 {
45179 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",7);
45180 }
45181
45182 if(!p_iputl(guysbuf[i].tile,f))
45183 {
45184 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",8);
45185 }
45186
45187 if(!p_putc(guysbuf[i].width,f))
45188 {
45189 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",9);
45190 }
45191
45192 if(!p_putc(guysbuf[i].height,f))
45193 {
45194 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",10);
45195 }
45196
45197 if(!p_iputl(guysbuf[i].s_tile,f))
45198 {
45199 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",11);
45200 }
45201
45202 if(!p_putc(guysbuf[i].s_width,f))
45203 {
45204 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",12);
45205 }
45206
45207 if(!p_putc(guysbuf[i].s_height,f))
45208 {
45209 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",13);
45210 }
45211
45212 if(!p_iputl(guysbuf[i].e_tile,f))
45213 {
45214 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",14);
45215 }
45216
45217 if(!p_putc(guysbuf[i].e_width,f))
45218 {
45219 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",15);
45220 }
45221
45222 if(!p_putc(guysbuf[i].e_height,f))
45223 {
45224 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",16);
45225 }
45226
45227 if(!p_iputw(guysbuf[i].hp,f))
45228 {
45229 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",17);
45230 }
45231
45232 if(!p_iputw(guysbuf[i].family,f))
45233 {
45234 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",18);
45235 }
45236
45237 if(!p_iputw(guysbuf[i].cset,f))
45238 {
45239 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",19);
45240 }
45241
45242 if(!p_iputw(guysbuf[i].anim,f))
45243 {
45244 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",20);
45245 }
45246
45247 if(!p_iputw(guysbuf[i].e_anim,f))
45248 {
45249 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",21);
45250 }
45251
45252 if(!p_iputw(guysbuf[i].frate,f))
45253 {
45254 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",22);
45255 }
45256
45257 if(!p_iputw(guysbuf[i].e_frate,f))
45258 {
45259 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",23);
45260 }
45261
45262 if(!p_iputw(guysbuf[i].dp,f))
45263 {
45264 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",24);
45265 }
45266
45267 if(!p_iputw(guysbuf[i].wdp,f))
45268 {
45269 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",25);
45270 }
45271
45272 if(!p_iputw(guysbuf[i].weapon,f))
45273 {
45274 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",26);
45275 }
45276
45277 if(!p_iputw(guysbuf[i].rate,f))
45278 {
45279 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",27);
45280 }
45281
45282 if(!p_iputw(guysbuf[i].hrate,f))
45283 {
45284 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",28);
45285 }
45286
45287 if(!p_iputw(guysbuf[i].step,f))
45288 {
45289 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",29);
45290 }
45291
45292 if(!p_iputw(guysbuf[i].homing,f))
45293 {
45294 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",30);
45295 }
45296
45297 if(!p_iputw(guysbuf[i].grumble,f))
45298 {
45299 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",31);
45300 }
45301
45302 if(!p_iputw(guysbuf[i].item_set,f))
45303 {
45304 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",32);
45305 }
45306
45307 if(!p_iputl(guysbuf[i].misc1,f))
45308 {
45309 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",33);
45310 }
45311
45312 if(!p_iputl(guysbuf[i].misc2,f))
45313 {
45314 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",34);
45315 }
45316
45317 if(!p_iputl(guysbuf[i].misc3,f))
45318 {
45319 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",35);
45320 }
45321
45322 if(!p_iputl(guysbuf[i].misc4,f))
45323 {
45324 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",36);
45325 }
45326
45327 if(!p_iputl(guysbuf[i].misc5,f))
45328 {
45329 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",37);
45330 }
45331
45332 if(!p_iputl(guysbuf[i].misc6,f))
45333 {
45334 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",38);
45335 }
45336
45337 if(!p_iputl(guysbuf[i].misc7,f))
45338 {
45339 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",39);
45340 }
45341
45342 if(!p_iputl(guysbuf[i].misc8,f))
45343 {
45344 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",40);
45345 }
45346
45347 if(!p_iputl(guysbuf[i].misc9,f))
45348 {
45349 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",41);
45350 }
45351
45352 if(!p_iputl(guysbuf[i].misc10,f))
45353 {
45354 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",42);
45355 }
45356
45357 if(!p_iputw(guysbuf[i].bgsfx,f))
45358 {
45359 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",43);
45360 }
45361
45362 if(!p_iputw(guysbuf[i].bosspal,f))
45363 {
45364 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",44);
45365 }
45366
45367 if(!p_iputw(guysbuf[i].extend,f))
45368 {
45369 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",45);
45370 }
45371
45372 for(int32_t j=0; j < edefLAST; j++)
45373 {
45374 if(!p_putc(guysbuf[i].defense[j],f))
45375 {
45376 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",46);
45377 }
45378 }
45379
45380 if(!p_putc(guysbuf[i].hitsfx,f))
45381 {
45382 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",47);
45383 }
45384
45385 if(!p_putc(guysbuf[i].deadsfx,f))
45386 {
45387 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",48);
45388 }
45389
45390 if(!p_iputl(guysbuf[i].misc11,f))
45391 {
45392 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",49);
45393 }
45394
45395 if(!p_iputl(guysbuf[i].misc12,f))
45396 {
45397 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",50);
45398 }
45399
45400 //New 2.6 defences
45401 for(int32_t j=edefLAST; j < edefLAST255; j++)
45402 {
45403 if(!p_putc(guysbuf[i].defense[j],f))
45404 {
45405 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",51);
45406 }
45407 }
45408
45409 //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs
45410 if(!p_iputl(guysbuf[i].txsz,f))
45411 {
45412 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",52);
45413 }
45414 if(!p_iputl(guysbuf[i].tysz,f))
45415 {
45416 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",53);
45417 }
45418 if(!p_iputl(guysbuf[i].hxsz,f))
45419 {
45420 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",54);
45421 }
45422 if(!p_iputl(guysbuf[i].hysz,f))
45423 {
45424 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",55);
45425 }
45426 if(!p_iputl(guysbuf[i].hzsz,f))
45427 {
45428 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",56);
45429 }
45430 // These are not fixed types, but ints, so they are safe to use here.
45431 if(!p_iputl(guysbuf[i].hxofs,f))
45432 {
45433 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",57);
45434 }
45435 if(!p_iputl(guysbuf[i].hyofs,f))
45436 {
45437 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",58);
45438 }
45439 if(!p_iputl(guysbuf[i].xofs,f))
45440 {
45441 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",59);
45442 }
45443 if(!p_iputl(guysbuf[i].yofs,f))
45444 {
45445 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",60);
45446 }
45447 if(!p_iputl(guysbuf[i].zofs,f))
45448 {
45449 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",61);
45450 }
45451 if(!p_iputl(guysbuf[i].wpnsprite,f))
45452 {
45453 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",62);
45454 }
45455 if(!p_iputl(guysbuf[i].SIZEflags,f))
45456 {
45457 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",63);
45458 }
45459 if(!p_iputl(guysbuf[i].frozentile,f))
45460 {
45461 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",64);
45462 }
45463 if(!p_iputl(guysbuf[i].frozencset,f))
45464 {
45465 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",65);
45466 }
45467 if(!p_iputl(guysbuf[i].frozenclock,f))
45468 {
45469 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",66);
45470 }
45471
45472 for ( int32_t q = 0; q < 10; q++ )
45473 {
45474 if(!p_iputw(guysbuf[i].frozenmisc[q],f))
45475 {
45476 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",67);
45477 }
45478 }
45479 if(!p_iputw(guysbuf[i].firesfx,f))
45480 {
45481 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",68);
45482 }
45483 //misc 16->31
45484 if(!p_iputl(guysbuf[i].misc16,f))
45485 {
45486 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",69);
45487 }
45488 if(!p_iputl(guysbuf[i].misc17,f))
45489 {
45490 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",70);
45491 }
45492 if(!p_iputl(guysbuf[i].misc18,f))
45493 {
45494 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",71);
45495 }
45496 if(!p_iputl(guysbuf[i].misc19,f))
45497 {
45498 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",72);
45499 }
45500 if(!p_iputl(guysbuf[i].misc20,f))
45501 {
45502 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",73);
45503 }
45504 if(!p_iputl(guysbuf[i].misc21,f))
45505 {
45506 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",74);
45507 }
45508 if(!p_iputl(guysbuf[i].misc22,f))
45509 {
45510 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",75);
45511 }
45512 if(!p_iputl(guysbuf[i].misc23,f))
45513 {
45514 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",76);
45515 }
45516 if(!p_iputl(guysbuf[i].misc24,f))
45517 {
45518 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",77);
45519 }
45520 if(!p_iputl(guysbuf[i].misc25,f))
45521 {
45522 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",78);
45523 }
45524 if(!p_iputl(guysbuf[i].misc26,f))
45525 {
45526 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",79);
45527 }
45528 if(!p_iputl(guysbuf[i].misc27,f))
45529 {
45530 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",80);
45531 }
45532 if(!p_iputl(guysbuf[i].misc28,f))
45533 {
45534 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",81);
45535 }
45536 if(!p_iputl(guysbuf[i].misc29,f))
45537 {
45538 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",82);
45539 }
45540 if(!p_iputl(guysbuf[i].misc30,f))
45541 {
45542 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",83);
45543 }
45544 if(!p_iputl(guysbuf[i].misc31,f))
45545 {
45546 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",84);
45547 }
45548 if(!p_iputl(guysbuf[i].misc32,f))
45549 {
45550 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",85);
45551 }
45552 for ( int32_t q = 0; q < 32; q++ )
45553 {
45554 if(!p_iputl(guysbuf[i].movement[q],f))
45555 {
45556 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",86);
45557 }
45558 }
45559 for ( int32_t q = 0; q < 32; q++ )
45560 {
45561 if(!p_iputl(guysbuf[i].new_weapon[q],f))
45562 {
45563 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",87);
45564 }
45565 }
45566 if(!p_iputw(guysbuf[i].script,f))
45567 {
45568 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",88);
45569 }
45570 for ( int32_t q = 0; q < 8; q++ )
45571 {
45572 if(!p_iputl(guysbuf[i].initD[q],f))
45573 {
45574 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",89);
45575 }
45576 }
45577 for ( int32_t q = 0; q < 2; q++ )
45578 {
45579 if(!p_iputl(guysbuf[i].initA[q],f))
45580 {
45581 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",90);
45582 }
45583 }
45584 if(!p_iputl(guysbuf[i].editorflags,f))
45585 {
45586 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",91);
45587 }
45588 //somehow forgot these in the older builds -Z
45589 if(!p_iputl(guysbuf[i].misc13,f))
45590 {
45591 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",92);
45592 }
45593 if(!p_iputl(guysbuf[i].misc14,f))
45594 {
45595 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",93);
45596 }
45597 if(!p_iputl(guysbuf[i].misc15,f))
45598 {
45599 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",94);
45600 }
45601
45602 //Enemy Editor InitD[] labels
45603 for ( int32_t q = 0; q < 8; q++ )
45604 {
45605 for ( int32_t w = 0; w < 65; w++ )
45606 {
45607 if(!p_putc(guysbuf[i].initD_label[q][w],f))
45608 {
45609 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",95);
45610 }
45611 }
45612 for ( int32_t w = 0; w < 65; w++ )
45613 {
45614 if(!p_putc(guysbuf[i].weapon_initD_label[q][w],f))
45615 {
45616 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",96);
45617 }
45618 }
45619 }
45620 if(!p_iputw(guysbuf[i].weaponscript,f))
45621 {
45622 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",97);
45623 }
45624 //eweapon initD
45625 for ( int32_t q = 0; q < 8; q++ )
45626 {
45627 if(!p_iputl(guysbuf[i].weap_initiald[q],f))
45628 {
45629 Z_scripterrlog("do_savegamestructs FAILED to write GUY NODE: %d",98);
45630 }
45631 }
45632
45633 }
45634 }
45635
45636
45637 void FFScript::write_items(PACKFILE *f, int32_t vers_id)
45638 {
45639 for(int32_t i=0; i<MAXITEMS; i++)
45640 {
45641 if(!p_iputl(itemsbuf[i].tile,f))
45642 {
45643 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",6);
45644 }
45645
45646 if(!p_putc(itemsbuf[i].misc_flags,f))
45647 {
45648 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",7);
45649 }
45650
45651 if(!p_putc(itemsbuf[i].csets,f))
45652 {
45653 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",8);
45654 }
45655
45656 if(!p_putc(itemsbuf[i].frames,f))
45657 {
45658 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",9);
45659 }
45660
45661 if(!p_putc(itemsbuf[i].speed,f))
45662 {
45663 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",10);
45664 }
45665
45666 if(!p_putc(itemsbuf[i].delay,f))
45667 {
45668 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",11);
45669 }
45670
45671 if(!p_iputl(itemsbuf[i].ltm,f))
45672 {
45673 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",12);
45674 }
45675
45676 if(!p_iputl(itemsbuf[i].family,f))
45677 {
45678 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",13);
45679 }
45680
45681 if(!p_putc(itemsbuf[i].fam_type,f))
45682 {
45683 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",14);
45684 }
45685
45686 if(!p_iputl(itemsbuf[i].power,f))
45687 {
45688 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",14);
45689 }
45690
45691 if(!p_iputl(itemsbuf[i].flags,f))
45692 {
45693 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",15);
45694 }
45695
45696 if(!p_iputw(itemsbuf[i].script,f))
45697 {
45698 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",16);
45699 }
45700
45701 if(!p_putc(itemsbuf[i].count,f))
45702 {
45703 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",17);
45704 }
45705
45706 if(!p_iputw(itemsbuf[i].amount,f))
45707 {
45708 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",18);
45709 }
45710
45711 if(!p_iputw(itemsbuf[i].collect_script,f))
45712 {
45713 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",19);
45714 }
45715
45716 if(!p_iputw(itemsbuf[i].setmax,f))
45717 {
45718 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",21);
45719 }
45720
45721 if(!p_iputw(itemsbuf[i].max,f))
45722 {
45723 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",22);
45724 }
45725
45726 if(!p_putc(itemsbuf[i].playsound,f))
45727 {
45728 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",23);
45729 }
45730
45731 for(int32_t j=0; j<8; j++)
45732 {
45733 if(!p_iputl(itemsbuf[i].initiald[j],f))
45734 {
45735 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",24);
45736 }
45737 }
45738
45739 for(int32_t j=0; j<2; j++)
45740 {
45741 if(!p_putc(itemsbuf[i].initiala[j],f))
45742 {
45743 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",25);
45744 }
45745 }
45746
45747 if(!p_putc(itemsbuf[i].wpn,f))
45748 {
45749 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",26);
45750 }
45751
45752 if(!p_putc(itemsbuf[i].wpn2,f))
45753 {
45754 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",27);
45755 }
45756
45757 if(!p_putc(itemsbuf[i].wpn3,f))
45758 {
45759 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",28);
45760 }
45761
45762 if(!p_putc(itemsbuf[i].wpn4,f))
45763 {
45764 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",29);
45765 }
45766
45767 if(!p_putc(itemsbuf[i].wpn5,f))
45768 {
45769 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",30);
45770 }
45771
45772 if(!p_putc(itemsbuf[i].wpn6,f))
45773 {
45774 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",31);
45775 }
45776
45777 if(!p_putc(itemsbuf[i].wpn7,f))
45778 {
45779 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",32);
45780 }
45781
45782 if(!p_putc(itemsbuf[i].wpn8,f))
45783 {
45784 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",33);
45785 }
45786
45787 if(!p_putc(itemsbuf[i].wpn9,f))
45788 {
45789 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",34);
45790 }
45791
45792 if(!p_putc(itemsbuf[i].wpn10,f))
45793 {
45794 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",35);
45795 }
45796
45797 if(!p_putc(itemsbuf[i].pickup_hearts,f))
45798 {
45799 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",36);
45800 }
45801
45802 if(!p_iputl(itemsbuf[i].misc1,f))
45803 {
45804 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",37);
45805 }
45806
45807 if(!p_iputl(itemsbuf[i].misc2,f))
45808 {
45809 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",38);
45810 }
45811
45812 if(!p_putc(itemsbuf[i].cost_amount[0],f))
45813 {
45814 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",39);
45815 }
45816
45817 if(!p_iputl(itemsbuf[i].misc3,f))
45818 {
45819 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",40);
45820 }
45821
45822 if(!p_iputl(itemsbuf[i].misc4,f))
45823 {
45824 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",41);
45825 }
45826
45827 if(!p_iputl(itemsbuf[i].misc5,f))
45828 {
45829 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",42);
45830 }
45831
45832 if(!p_iputl(itemsbuf[i].misc6,f))
45833 {
45834 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",43);
45835 }
45836
45837 if(!p_iputl(itemsbuf[i].misc7,f))
45838 {
45839 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",44);
45840 }
45841
45842 if(!p_iputl(itemsbuf[i].misc8,f))
45843 {
45844 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",45);
45845 }
45846
45847 if(!p_iputl(itemsbuf[i].misc9,f))
45848 {
45849 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",46);
45850 }
45851
45852 if(!p_iputl(itemsbuf[i].misc10,f))
45853 {
45854 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",47);
45855 }
45856
45857 if(!p_putc(itemsbuf[i].usesound,f))
45858 {
45859 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",48);
45860 }
45861
45862 if(!p_putc(itemsbuf[i].usesound2,f))
45863 {
45864 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",48);
45865 }
45866
45867 //New itemdata vars -Z
45868 //! version 27
45869
45870 if(!p_putc(itemsbuf[i].useweapon,f))
45871 {
45872 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",49);
45873 }
45874 if(!p_putc(itemsbuf[i].usedefence,f))
45875 {
45876 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",50);
45877 }
45878 if(!p_iputl(itemsbuf[i].weaprange,f))
45879 {
45880 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",51);
45881 }
45882 if(!p_iputl(itemsbuf[i].weapduration,f))
45883 {
45884 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",52);
45885 }
45886 for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ ) {
45887 if(!p_iputl(itemsbuf[i].weap_pattern[q],f))
45888 {
45889 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",53);
45890 }
45891 }
45892 //version 28
45893 if(!p_iputl(itemsbuf[i].duplicates,f))
45894 {
45895 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",54);
45896 }
45897 for ( int32_t q = 0; q < INITIAL_D; q++ )
45898 {
45899 if(!p_iputl(itemsbuf[i].weap_initiald[q],f))
45900 {
45901 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",55);
45902 }
45903 }
45904 for ( int32_t q = 0; q < INITIAL_A; q++ )
45905 {
45906 if(!p_putc(itemsbuf[i].weap_initiala[q],f))
45907 {
45908 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",56);
45909 }
45910 }
45911
45912 if(!p_putc(itemsbuf[i].drawlayer,f))
45913 {
45914 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",57);
45915 }
45916
45917
45918 if(!p_iputl(itemsbuf[i].hxofs,f))
45919 {
45920 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",58);
45921 }
45922 if(!p_iputl(itemsbuf[i].hyofs,f))
45923 {
45924 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",59);
45925 }
45926 if(!p_iputl(itemsbuf[i].hxsz,f))
45927 {
45928 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",60);
45929 }
45930 if(!p_iputl(itemsbuf[i].hysz,f))
45931 {
45932 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",61);
45933 }
45934 if(!p_iputl(itemsbuf[i].hzsz,f))
45935 {
45936 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",62);
45937 }
45938 if(!p_iputl(itemsbuf[i].xofs,f))
45939 {
45940 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",63);
45941 }
45942 if(!p_iputl(itemsbuf[i].yofs,f))
45943 {
45944 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",64);
45945 }
45946 if(!p_iputl(itemsbuf[i].weap_hxofs,f))
45947 {
45948 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",65);
45949 }
45950 if(!p_iputl(itemsbuf[i].weap_hyofs,f))
45951 {
45952 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",66);
45953 }
45954 if(!p_iputl(itemsbuf[i].weap_hxsz,f))
45955 {
45956 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",67);
45957 }
45958 if(!p_iputl(itemsbuf[i].weap_hysz,f))
45959 {
45960 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",68);
45961 }
45962 if(!p_iputl(itemsbuf[i].weap_hzsz,f))
45963 {
45964 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",69);
45965 }
45966 if(!p_iputl(itemsbuf[i].weap_xofs,f))
45967 {
45968 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",70);
45969 }
45970 if(!p_iputl(itemsbuf[i].weap_yofs,f))
45971 {
45972 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",71);
45973 }
45974 if(!p_iputw(itemsbuf[i].weaponscript,f))
45975 {
45976 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",72);
45977 }
45978 if(!p_iputl(itemsbuf[i].wpnsprite,f))
45979 {
45980 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",73);
45981 }
45982 if(!p_iputl(itemsbuf[i].magiccosttimer[0],f))
45983 {
45984 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",74);
45985 }
45986 if(!p_iputl(itemsbuf[i].overrideFLAGS,f))
45987 {
45988 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",75);
45989 }
45990 if(!p_iputl(itemsbuf[i].tilew,f))
45991 {
45992 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",76);
45993 }
45994 if(!p_iputl(itemsbuf[i].tileh,f))
45995 {
45996 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",77);
45997 }
45998 if(!p_iputl(itemsbuf[i].weapoverrideFLAGS,f))
45999 {
46000 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",78);
46001 }
46002 if(!p_iputl(itemsbuf[i].weap_tilew,f))
46003 {
46004 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",79);
46005 }
46006 if(!p_iputl(itemsbuf[i].weap_tileh,f))
46007 {
46008 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",80);
46009 }
46010 if(!p_iputl(itemsbuf[i].pickup,f))
46011 {
46012 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",81);
46013 }
46014 if(!p_iputw(itemsbuf[i].pstring,f))
46015 {
46016 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",82);
46017 }
46018 if(!p_iputw(itemsbuf[i].pickup_string_flags,f))
46019 {
46020 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",83);
46021 }
46022
46023 if(!p_putc(itemsbuf[i].cost_counter[0],f))
46024 {
46025 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",84);
46026 }
46027
46028 //InitD[] labels
46029 for ( int32_t q = 0; q < 8; q++ )
46030 {
46031 for ( int32_t w = 0; w < 65; w++ )
46032 {
46033 if(!p_putc(itemsbuf[i].initD_label[q][w],f))
46034 {
46035 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",85);
46036 }
46037 }
46038 for ( int32_t w = 0; w < 65; w++ )
46039 {
46040 if(!p_putc(itemsbuf[i].weapon_initD_label[q][w],f))
46041 {
46042 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",86);
46043 }
46044 }
46045 for ( int32_t w = 0; w < 65; w++ )
46046 {
46047 if(!p_putc(itemsbuf[i].sprite_initD_label[q][w],f))
46048 {
46049 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",87);
46050 }
46051 }
46052 if(!p_iputl(itemsbuf[i].sprite_initiald[q],f))
46053 {
46054 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",88);
46055 }
46056 }
46057 for ( int32_t q = 0; q < 2; q++ )
46058 {
46059 if(!p_putc(itemsbuf[i].sprite_initiala[q],f))
46060 {
46061 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",89);
46062 }
46063
46064 }
46065 if(!p_iputw(itemsbuf[i].sprite_script,f))
46066 {
46067 Z_scripterrlog("do_savegamestructs FAILED to read ITEM NODE: %d",90);
46068 }
46069
46070
46071 }
46072 }
46073
46074 void FFScript::read_items(PACKFILE *f, int32_t vers_id)
46075 {
46076 for(int32_t i=0; i<MAXITEMS; i++)
46077 {
46078 if(!p_igetl(&itemsbuf[i].tile,f))
46079 {
46080 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",6);
46081 }
46082
46083 if(!p_getc(&itemsbuf[i].misc_flags,f))
46084 {
46085 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",7);
46086 }
46087
46088 if(!p_getc(&itemsbuf[i].csets,f))
46089 {
46090 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",8);
46091 }
46092
46093 if(!p_getc(&itemsbuf[i].frames,f))
46094 {
46095 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",9);
46096 }
46097
46098 if(!p_getc(&itemsbuf[i].speed,f))
46099 {
46100 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",10);
46101 }
46102
46103 if(!p_getc(&itemsbuf[i].delay,f))
46104 {
46105 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",11);
46106 }
46107
46108 if(!p_igetl(&itemsbuf[i].ltm,f))
46109 {
46110 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",12);
46111 }
46112
46113 if(!p_igetl(&itemsbuf[i].family,f))
46114 {
46115 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",13);
46116 }
46117
46118 if(!p_getc(&itemsbuf[i].fam_type,f))
46119 {
46120 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",14);
46121 }
46122
46123 if(!p_igetl(&itemsbuf[i].power,f))
46124 {
46125 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",14);
46126 }
46127
46128 if(!p_igetl(&itemsbuf[i].flags,f))
46129 {
46130 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",15);
46131 }
46132
46133 if(!p_igetw(&itemsbuf[i].script,f))
46134 {
46135 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",16);
46136 }
46137
46138 if(!p_getc(&itemsbuf[i].count,f))
46139 {
46140 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",17);
46141 }
46142
46143 if(!p_igetw(&itemsbuf[i].amount,f))
46144 {
46145 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",18);
46146 }
46147
46148 if(!p_igetw(&itemsbuf[i].collect_script,f))
46149 {
46150 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",19);
46151 }
46152
46153 if(!p_igetw(&itemsbuf[i].setmax,f))
46154 {
46155 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",21);
46156 }
46157
46158 if(!p_igetw(&itemsbuf[i].max,f))
46159 {
46160 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",22);
46161 }
46162
46163 if(!p_getc(&itemsbuf[i].playsound,f))
46164 {
46165 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",23);
46166 }
46167
46168 for(int32_t j=0; j<8; j++)
46169 {
46170 if(!p_igetl(&itemsbuf[i].initiald[j],f))
46171 {
46172 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",24);
46173 }
46174 }
46175
46176 for(int32_t j=0; j<2; j++)
46177 {
46178 if(!p_getc(&itemsbuf[i].initiala[j],f))
46179 {
46180 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",25);
46181 }
46182 }
46183
46184 if(!p_getc(&itemsbuf[i].wpn,f))
46185 {
46186 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",26);
46187 }
46188
46189 if(!p_getc(&itemsbuf[i].wpn2,f))
46190 {
46191 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",27);
46192 }
46193
46194 if(!p_getc(&itemsbuf[i].wpn3,f))
46195 {
46196 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",28);
46197 }
46198
46199 if(!p_getc(&itemsbuf[i].wpn4,f))
46200 {
46201 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",29);
46202 }
46203
46204 if(!p_getc(&itemsbuf[i].wpn5,f))
46205 {
46206 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",30);
46207 }
46208
46209 if(!p_getc(&itemsbuf[i].wpn6,f))
46210 {
46211 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",31);
46212 }
46213
46214 if(!p_getc(&itemsbuf[i].wpn7,f))
46215 {
46216 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",32);
46217 }
46218
46219 if(!p_getc(&itemsbuf[i].wpn8,f))
46220 {
46221 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",33);
46222 }
46223
46224 if(!p_getc(&itemsbuf[i].wpn9,f))
46225 {
46226 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",34);
46227 }
46228
46229 if(!p_getc(&itemsbuf[i].wpn10,f))
46230 {
46231 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",35);
46232 }
46233
46234 if(!p_getc(&itemsbuf[i].pickup_hearts,f))
46235 {
46236 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",36);
46237 }
46238
46239 if(!p_igetl(&itemsbuf[i].misc1,f))
46240 {
46241 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",37);
46242 }
46243
46244 if(!p_igetl(&itemsbuf[i].misc2,f))
46245 {
46246 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",38);
46247 }
46248
46249 if(!p_getc(&itemsbuf[i].cost_amount[0],f))
46250 {
46251 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",39);
46252 }
46253
46254 if(!p_igetl(&itemsbuf[i].misc3,f))
46255 {
46256 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",40);
46257 }
46258
46259 if(!p_igetl(&itemsbuf[i].misc4,f))
46260 {
46261 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",41);
46262 }
46263
46264 if(!p_igetl(&itemsbuf[i].misc5,f))
46265 {
46266 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",42);
46267 }
46268
46269 if(!p_igetl(&itemsbuf[i].misc6,f))
46270 {
46271 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",43);
46272 }
46273
46274 if(!p_igetl(&itemsbuf[i].misc7,f))
46275 {
46276 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",44);
46277 }
46278
46279 if(!p_igetl(&itemsbuf[i].misc8,f))
46280 {
46281 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",45);
46282 }
46283
46284 if(!p_igetl(&itemsbuf[i].misc9,f))
46285 {
46286 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",46);
46287 }
46288
46289 if(!p_igetl(&itemsbuf[i].misc10,f))
46290 {
46291 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",47);
46292 }
46293
46294 if(!p_getc(&itemsbuf[i].usesound,f))
46295 {
46296 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",48);
46297 }
46298
46299 if(!p_getc(&itemsbuf[i].usesound2,f))
46300 {
46301 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",48);
46302 }
46303
46304 //New itemdata vars -Z
46305 //! version 27
46306
46307 if(!p_getc(&itemsbuf[i].useweapon,f))
46308 {
46309 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",49);
46310 }
46311 if(!p_getc(&itemsbuf[i].usedefence,f))
46312 {
46313 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",50);
46314 }
46315 if(!p_igetl(&itemsbuf[i].weaprange,f))
46316 {
46317 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",51);
46318 }
46319 if(!p_igetl(&itemsbuf[i].weapduration,f))
46320 {
46321 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",52);
46322 }
46323 for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ ) {
46324 if(!p_igetl(&itemsbuf[i].weap_pattern[q],f))
46325 {
46326 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",53);
46327 }
46328 }
46329 //version 28
46330 if(!p_igetl(&itemsbuf[i].duplicates,f))
46331 {
46332 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",54);
46333 }
46334 for ( int32_t q = 0; q < INITIAL_D; q++ )
46335 {
46336 if(!p_igetl(&itemsbuf[i].weap_initiald[q],f))
46337 {
46338 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",55);
46339 }
46340 }
46341 for ( int32_t q = 0; q < INITIAL_A; q++ )
46342 {
46343 if(!p_getc(&itemsbuf[i].weap_initiala[q],f))
46344 {
46345 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",56);
46346 }
46347 }
46348
46349 if(!p_getc(&itemsbuf[i].drawlayer,f))
46350 {
46351 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",57);
46352 }
46353
46354
46355 if(!p_igetl(&itemsbuf[i].hxofs,f))
46356 {
46357 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",58);
46358 }
46359 if(!p_igetl(&itemsbuf[i].hyofs,f))
46360 {
46361 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",59);
46362 }
46363 if(!p_igetl(&itemsbuf[i].hxsz,f))
46364 {
46365 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",60);
46366 }
46367 if(!p_igetl(&itemsbuf[i].hysz,f))
46368 {
46369 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",61);
46370 }
46371 if(!p_igetl(&itemsbuf[i].hzsz,f))
46372 {
46373 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",62);
46374 }
46375 if(!p_igetl(&itemsbuf[i].xofs,f))
46376 {
46377 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",63);
46378 }
46379 if(!p_igetl(&itemsbuf[i].yofs,f))
46380 {
46381 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",64);
46382 }
46383 if(!p_igetl(&itemsbuf[i].weap_hxofs,f))
46384 {
46385 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",65);
46386 }
46387 if(!p_igetl(&itemsbuf[i].weap_hyofs,f))
46388 {
46389 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",66);
46390 }
46391 if(!p_igetl(&itemsbuf[i].weap_hxsz,f))
46392 {
46393 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",67);
46394 }
46395 if(!p_igetl(&itemsbuf[i].weap_hysz,f))
46396 {
46397 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",68);
46398 }
46399 if(!p_igetl(&itemsbuf[i].weap_hzsz,f))
46400 {
46401 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",69);
46402 }
46403 if(!p_igetl(&itemsbuf[i].weap_xofs,f))
46404 {
46405 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",70);
46406 }
46407 if(!p_igetl(&itemsbuf[i].weap_yofs,f))
46408 {
46409 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",71);
46410 }
46411 if(!p_igetw(&itemsbuf[i].weaponscript,f))
46412 {
46413 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",72);
46414 }
46415 if(!p_igetl(&itemsbuf[i].wpnsprite,f))
46416 {
46417 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",73);
46418 }
46419 if(!p_igetl(&itemsbuf[i].magiccosttimer[0],f))
46420 {
46421 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",74);
46422 }
46423 if(!p_igetl(&itemsbuf[i].overrideFLAGS,f))
46424 {
46425 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",75);
46426 }
46427 if(!p_igetl(&itemsbuf[i].tilew,f))
46428 {
46429 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",76);
46430 }
46431 if(!p_igetl(&itemsbuf[i].tileh,f))
46432 {
46433 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",77);
46434 }
46435 if(!p_igetl(&itemsbuf[i].weapoverrideFLAGS,f))
46436 {
46437 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",78);
46438 }
46439 if(!p_igetl(&itemsbuf[i].weap_tilew,f))
46440 {
46441 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",79);
46442 }
46443 if(!p_igetl(&itemsbuf[i].weap_tileh,f))
46444 {
46445 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",80);
46446 }
46447 if(!p_igetl(&itemsbuf[i].pickup,f))
46448 {
46449 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",81);
46450 }
46451 if(!p_igetw(&itemsbuf[i].pstring,f))
46452 {
46453 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",82);
46454 }
46455 if(!p_igetw(&itemsbuf[i].pickup_string_flags,f))
46456 {
46457 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",83);
46458 }
46459
46460 if(!p_getc(&itemsbuf[i].cost_counter[0],f))
46461 {
46462 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",84);
46463 }
46464
46465 //InitD[] labels
46466 for ( int32_t q = 0; q < 8; q++ )
46467 {
46468 for ( int32_t w = 0; w < 65; w++ )
46469 {
46470 if(!p_getc(&itemsbuf[i].initD_label[q][w],f))
46471 {
46472 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",85);
46473 }
46474 }
46475 for ( int32_t w = 0; w < 65; w++ )
46476 {
46477 if(!p_getc(&itemsbuf[i].weapon_initD_label[q][w],f))
46478 {
46479 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",86);
46480 }
46481 }
46482 for ( int32_t w = 0; w < 65; w++ )
46483 {
46484 if(!p_getc(&itemsbuf[i].sprite_initD_label[q][w],f))
46485 {
46486 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",87);
46487 }
46488 }
46489 if(!p_igetl(&itemsbuf[i].sprite_initiald[q],f))
46490 {
46491 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",88);
46492 }
46493 }
46494 for ( int32_t q = 0; q < 2; q++ )
46495 {
46496 if(!p_getc(&itemsbuf[i].sprite_initiala[q],f))
46497 {
46498 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",89);
46499 }
46500
46501 }
46502 if(!p_igetw(&itemsbuf[i].sprite_script,f))
46503 {
46504 Z_scripterrlog("do_savegamestructs FAILED to write ITEM NODE: %d",90);
46505 }
46506
46507
46508 }
46509 }
46510
46511 void FFScript::write_mapscreens(PACKFILE *f,int32_t vers_id)
46512 {
46513 for(int32_t i=0; i<map_count && i<MAXMAPS2; i++)
46514 {
46515 for(int32_t j=0; j<MAPSCRS; j++)
46516 {
46517 mapscr *m = &TheMaps[i*MAPSCRS+j];
46518
46519 if(!p_putc(m->valid,f))
46520 {
46521 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46522 }
46523
46524 if(!p_putc(m->guy,f))
46525 {
46526 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46527 }
46528
46529 {
46530 if(!p_iputw(m->str,f))
46531 {
46532 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46533 }
46534 }
46535
46536 if(!p_putc(m->room,f))
46537 {
46538 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46539 }
46540
46541 if(!p_putc(m->item,f))
46542 {
46543 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46544 }
46545
46546 if(!p_putc(m->hasitem, f))
46547 {
46548 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46549 }
46550
46551 for(int32_t k=0; k<4; k++)
46552 {
46553 if(!p_putc(m->tilewarptype[k],f))
46554 {
46555 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46556 }
46557 }
46558
46559 if(!p_iputw(m->door_combo_set,f))
46560 {
46561 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46562 }
46563
46564 for(int32_t k=0; k<4; k++)
46565 {
46566 if(!p_putc(m->warpreturnx[k],f))
46567 {
46568 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46569 }
46570 }
46571
46572 for(int32_t k=0; k<4; k++)
46573 {
46574 if(!p_putc(m->warpreturny[k],f))
46575 {
46576 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46577 }
46578 }
46579
46580 if(!p_iputw(m->warpreturnc,f))
46581 {
46582 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46583 }
46584
46585 if(!p_putc(m->stairx,f))
46586 {
46587 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46588 }
46589
46590 if(!p_putc(m->stairy,f))
46591 {
46592 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46593 }
46594
46595 if(!p_putc(m->itemx,f))
46596 {
46597 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46598 }
46599
46600 if(!p_putc(m->itemy,f))
46601 {
46602 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46603 }
46604
46605 if(!p_iputw(m->color,f))
46606 {
46607 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46608 }
46609
46610 if(!p_putc(m->enemyflags,f))
46611 {
46612 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46613 }
46614
46615 for(int32_t k=0; k<4; k++)
46616 {
46617 if(!p_putc(m->door[k],f))
46618 {
46619 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46620 }
46621 }
46622
46623 for(int32_t k=0; k<4; k++)
46624 {
46625 if(!p_iputw(m->tilewarpdmap[k],f))
46626 {
46627 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46628 }
46629 }
46630
46631 for(int32_t k=0; k<4; k++)
46632 {
46633 if(!p_putc(m->tilewarpscr[k],f))
46634 {
46635 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46636 }
46637 }
46638
46639 if(!p_putc(m->tilewarpoverlayflags,f))
46640 {
46641 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46642 }
46643
46644 if(!p_putc(m->exitdir,f))
46645 {
46646 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46647 }
46648
46649 for(int32_t k=0; k<10; k++)
46650 {
46651 {
46652 if(!p_iputw(m->enemy[k],f))
46653 {
46654 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46655 }
46656 }
46657 }
46658
46659 if(!p_putc(m->pattern,f))
46660 {
46661 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46662 }
46663
46664 for(int32_t k=0; k<4; k++)
46665 {
46666 if(!p_putc(m->sidewarptype[k],f))
46667 {
46668 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46669 }
46670 }
46671
46672 if(!p_putc(m->sidewarpoverlayflags,f))
46673 {
46674 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46675 }
46676
46677 if(!p_putc(m->warparrivalx,f))
46678 {
46679 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46680 }
46681
46682 if(!p_putc(m->warparrivaly,f))
46683 {
46684 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46685 }
46686
46687 for(int32_t k=0; k<4; k++)
46688 {
46689 if(!p_putc(m->path[k],f))
46690 {
46691 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46692 }
46693 }
46694
46695 for(int32_t k=0; k<4; k++)
46696 {
46697 if(!p_putc(m->sidewarpscr[k],f))
46698 {
46699 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46700 }
46701 }
46702
46703 for(int32_t k=0; k<4; k++)
46704 {
46705 if(!p_iputw(m->sidewarpdmap[k],f))
46706 {
46707 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46708 }
46709 }
46710
46711 if(!p_putc(m->sidewarpindex,f))
46712 {
46713 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46714 }
46715
46716 if(!p_iputw(m->undercombo,f))
46717 {
46718 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46719 }
46720
46721 if(!p_putc(m->undercset,f))
46722 {
46723 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46724 }
46725
46726 if(!p_iputw(m->catchall,f))
46727 {
46728 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46729 }
46730
46731 if(!p_putc(m->flags,f))
46732 {
46733 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46734 }
46735
46736 if(!p_putc(m->flags2,f))
46737 {
46738 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46739 }
46740
46741 if(!p_putc(m->flags3,f))
46742 {
46743 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46744 }
46745
46746 if(!p_putc(m->flags4,f))
46747 {
46748 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46749 }
46750
46751 if(!p_putc(m->flags5,f))
46752 {
46753 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46754 }
46755
46756 if(!p_iputw(m->noreset,f))
46757 {
46758 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46759 }
46760
46761 if(!p_iputw(m->nocarry,f))
46762 {
46763 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46764 }
46765
46766 if(!p_putc(m->flags6,f))
46767 {
46768 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46769 }
46770
46771 if(!p_putc(m->flags7,f))
46772 {
46773 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46774 }
46775
46776 if(!p_putc(m->flags8,f))
46777 {
46778 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46779 }
46780
46781 if(!p_putc(m->flags9,f))
46782 {
46783 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46784 }
46785
46786 if(!p_putc(m->flags10,f))
46787 {
46788 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46789 }
46790
46791 if(!p_putc(m->csensitive,f))
46792 {
46793 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46794 }
46795
46796 if(!p_putc(m->oceansfx,f))
46797 {
46798 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46799 }
46800
46801 if(!p_putc(m->bosssfx,f))
46802 {
46803 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46804 }
46805
46806 if(!p_putc(m->secretsfx,f))
46807 {
46808 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46809 }
46810
46811 if(!p_putc(m->holdupsfx,f))
46812 {
46813 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46814 }
46815
46816 for(int32_t k=0; k<6; k++)
46817 {
46818 if(!p_putc(m->layermap[k],f))
46819 {
46820 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46821 }
46822 }
46823
46824 for(int32_t k=0; k<6; k++)
46825 {
46826 if(!p_putc(m->layerscreen[k],f))
46827 {
46828 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46829 }
46830 }
46831
46832 for(int32_t k=0; k<6; k++)
46833 {
46834 if(!p_putc(m->layeropacity[k],f))
46835 {
46836 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46837 }
46838 }
46839
46840 if(!p_iputw(m->timedwarptics,f))
46841 {
46842 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46843 }
46844
46845 if(!p_putc(m->nextmap,f))
46846 {
46847 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46848 }
46849
46850 if(!p_putc(m->nextscr,f))
46851 {
46852 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46853 }
46854
46855 for(int32_t k=0; k<128; k++)
46856 {
46857 if(!p_iputw(m->secretcombo[k],f))
46858 {
46859 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46860 }
46861 }
46862
46863 for(int32_t k=0; k<128; k++)
46864 {
46865 if(!p_putc(m->secretcset[k],f))
46866 {
46867 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46868 }
46869 }
46870
46871 for(int32_t k=0; k<128; k++)
46872 {
46873 if(!p_putc(m->secretflag[k],f))
46874 {
46875 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46876 }
46877 }
46878
46879 for(int32_t k=0; k<(ZCMaps[i].tileWidth)*(ZCMaps[i].tileHeight); k++)
46880 {
46881 try
46882 {
46883 if(!p_iputw(m->data[k],f))
46884 {
46885 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46886 }
46887 }
46888 catch(std::out_of_range& )
46889 {
46890 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46891 }
46892 }
46893
46894 for(int32_t k=0; k<(ZCMaps[i].tileWidth)*(ZCMaps[i].tileHeight); k++)
46895 {
46896 try
46897 {
46898 if(!p_putc(m->sflag[k], f))
46899 {
46900 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46901 }
46902 }
46903 catch(std::out_of_range& )
46904 {
46905 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46906 }
46907 }
46908
46909 for(int32_t k=0; k<(ZCMaps[i].tileWidth)*(ZCMaps[i].tileHeight); k++)
46910 {
46911 try
46912 {
46913 if(!p_putc(m->cset[k],f))
46914 {
46915 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46916 }
46917 }
46918 catch(std::out_of_range& )
46919 {
46920 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46921 }
46922 }
46923
46924 if(!p_iputw(m->screen_midi,f))
46925 {
46926 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46927 }
46928
46929 if(!p_putc(m->lens_layer,f))
46930 {
46931 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46932 }
46933
46934 for(int32_t k=0; k<32; k++)
46935 {
46936
46937 if(!p_iputw(m->ffcs[k].getData(),f))
46938 {
46939 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46940 }
46941
46942 if(!p_putc(m->ffcs[k].cset,f))
46943 {
46944 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46945 }
46946
46947 if(!p_iputw(m->ffcs[k].delay,f))
46948 {
46949 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46950 }
46951
46952 if(!p_iputzf(m->ffcs[k].x,f))
46953 {
46954 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46955 }
46956
46957 if(!p_iputzf(m->ffcs[k].y,f))
46958 {
46959 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46960 }
46961
46962 if(!p_iputzf(m->ffcs[k].vx,f))
46963 {
46964 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46965 }
46966
46967 if(!p_iputzf(m->ffcs[k].vy,f))
46968 {
46969 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46970 }
46971
46972 if(!p_iputzf(m->ffcs[k].ax,f))
46973 {
46974 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46975 }
46976
46977 if(!p_iputzf(m->ffcs[k].ay,f))
46978 {
46979 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46980 }
46981
46982 if(!p_putc(m->ffcs[k].link,f))
46983 {
46984 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46985 }
46986
46987 if(!p_iputl(m->ffcs[k].hit_width,f))
46988 {
46989 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46990 }
46991
46992 if(!p_iputl(m->ffcs[k].hit_height,f))
46993 {
46994 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
46995 }
46996
46997 if(!p_putc(m->ffcs[k].txsz,f))
46998 {
46999 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
47000 }
47001
47002 if(!p_putc(m->ffcs[k].tysz,f))
47003 {
47004 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
47005 }
47006
47007 if(!p_iputl(m->ffcs[k].flags,f))
47008 {
47009 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
47010 }
47011
47012 if(!p_iputw(m->ffcs[k].script,f))
47013 {
47014 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
47015 }
47016
47017 if(!p_iputl(m->ffcs[k].initd[0],f))
47018 {
47019 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
47020 }
47021
47022 if(!p_iputl(m->ffcs[k].initd[1],f))
47023 {
47024 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
47025 }
47026
47027 if(!p_iputl(m->ffcs[k].initd[2],f))
47028 {
47029 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
47030 }
47031
47032 if(!p_iputl(m->ffcs[k].initd[3],f))
47033 {
47034 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
47035 }
47036
47037 if(!p_iputl(m->ffcs[k].initd[4],f))
47038 {
47039 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
47040 }
47041
47042 if(!p_iputl(m->ffcs[k].initd[5],f))
47043 {
47044 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
47045 }
47046
47047 if(!p_iputl(m->ffcs[k].initd[6],f))
47048 {
47049 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
47050 }
47051
47052 if(!p_iputl(m->ffcs[k].initd[7],f))
47053 {
47054 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
47055 }
47056
47057 }
47058
47059 for ( int32_t q = 0; q < 10; q++ )
47060 {
47061 if(!p_iputl(m->npcstrings[q],f))
47062 {
47063 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
47064 }
47065 }
47066 for ( int32_t q = 0; q < 10; q++ )
47067 {
47068 if(!p_iputw(m->new_items[q],f))
47069 {
47070 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
47071 }
47072 }
47073 for ( int32_t q = 0; q < 10; q++ )
47074 {
47075 if(!p_iputw(m->new_item_x[q],f))
47076 {
47077 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
47078 }
47079 }
47080 for ( int32_t q = 0; q < 10; q++ )
47081 {
47082 if(!p_iputw(m->new_item_y[q],f))
47083 {
47084 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
47085 }
47086 }
47087 if(!p_iputw(m->script,f))
47088 {
47089 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
47090 }
47091 for ( int32_t q = 0; q < 8; q++ )
47092 {
47093 if(!p_iputl(m->screeninitd[q],f))
47094 {
47095 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
47096 }
47097
47098 }
47099 if(!p_putc(m->preloadscript,f))
47100 {
47101 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
47102 }
47103
47104 if(!p_putc(m->hidelayers,f))
47105 {
47106 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
47107 }
47108 if(!p_putc(m->hidescriptlayers,f))
47109 {
47110 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODEz\n"); return;
47111 }
47112
47113
47114 } //end mapscr for loop
47115 }
47116 }
47117 void FFScript::read_mapscreens(PACKFILE *f,int32_t vers_id)
47118 {
47119 for(int32_t i=0; i<map_count && i<MAXMAPS2; i++)
47120 {
47121 for(int32_t j=0; j<MAPSCRS; j++)
47122 {
47123 mapscr *m = &TheMaps[i*MAPSCRS+j];
47124
47125 if(!p_getc(&(m->valid),f))
47126 {
47127 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47128 }
47129
47130 if(!p_getc(&(m->guy),f))
47131 {
47132 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47133 }
47134
47135 {
47136 if(!p_igetw(&(m->str),f))
47137 {
47138 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47139 }
47140 }
47141
47142 if(!p_getc(&(m->room),f))
47143 {
47144 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47145 }
47146
47147 if(!p_getc(&(m->item),f))
47148 {
47149 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47150 }
47151
47152 if(!p_getc(&(m->hasitem), f))
47153 {
47154 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47155 }
47156
47157 for(int32_t k=0; k<4; k++)
47158 {
47159 if(!p_getc(&(m->tilewarptype[k]),f))
47160 {
47161 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47162 }
47163 }
47164
47165 if(!p_igetw(&(m->door_combo_set),f))
47166 {
47167 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47168 }
47169
47170 for(int32_t k=0; k<4; k++)
47171 {
47172 if(!p_getc(&(m->warpreturnx[k]),f))
47173 {
47174 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47175 }
47176 }
47177
47178 for(int32_t k=0; k<4; k++)
47179 {
47180 if(!p_getc(&(m->warpreturny[k]),f))
47181 {
47182 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47183 }
47184 }
47185
47186 if(!p_igetw(&(m->warpreturnc),f))
47187 {
47188 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47189 }
47190
47191 if(!p_getc(&(m->stairx),f))
47192 {
47193 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47194 }
47195
47196 if(!p_getc(&(m->stairy),f))
47197 {
47198 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47199 }
47200
47201 if(!p_getc(&(m->itemx),f))
47202 {
47203 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47204 }
47205
47206 if(!p_getc(&(m->itemy),f))
47207 {
47208 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47209 }
47210
47211 if(!p_igetw(&(m->color),f))
47212 {
47213 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47214 }
47215
47216 if(!p_getc(&(m->enemyflags),f))
47217 {
47218 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47219 }
47220
47221 for(int32_t k=0; k<4; k++)
47222 {
47223 if(!p_getc(&(m->door[k]),f))
47224 {
47225 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47226 }
47227 }
47228
47229 for(int32_t k=0; k<4; k++)
47230 {
47231 if(!p_igetw(&(m->tilewarpdmap[k]),f))
47232 {
47233 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47234 }
47235 }
47236
47237 for(int32_t k=0; k<4; k++)
47238 {
47239 if(!p_getc(&(m->tilewarpscr[k]),f))
47240 {
47241 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47242 }
47243 }
47244
47245 if(!p_getc(&(m->tilewarpoverlayflags),f))
47246 {
47247 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47248 }
47249
47250 if(!p_getc(&(m->exitdir),f))
47251 {
47252 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47253 }
47254
47255 for(int32_t k=0; k<10; k++)
47256 {
47257 {
47258 if(!p_igetw(&(m->enemy[k]),f))
47259 {
47260 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47261 }
47262 }
47263 }
47264
47265 if(!p_getc(&(m->pattern),f))
47266 {
47267 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47268 }
47269
47270 for(int32_t k=0; k<4; k++)
47271 {
47272 if(!p_getc(&(m->sidewarptype[k]),f))
47273 {
47274 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47275 }
47276 }
47277
47278 if(!p_getc(&(m->sidewarpoverlayflags),f))
47279 {
47280 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47281 }
47282
47283 if(!p_getc(&(m->warparrivalx),f))
47284 {
47285 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47286 }
47287
47288 if(!p_getc(&(m->warparrivaly),f))
47289 {
47290 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47291 }
47292
47293 for(int32_t k=0; k<4; k++)
47294 {
47295 if(!p_getc(&(m->path[k]),f))
47296 {
47297 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47298 }
47299 }
47300
47301 for(int32_t k=0; k<4; k++)
47302 {
47303 if(!p_getc(&(m->sidewarpscr[k]),f))
47304 {
47305 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47306 }
47307 }
47308
47309 for(int32_t k=0; k<4; k++)
47310 {
47311 if(!p_igetw(&(m->sidewarpdmap[k]),f))
47312 {
47313 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47314 }
47315 }
47316
47317 if(!p_getc(&(m->sidewarpindex),f))
47318 {
47319 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47320 }
47321
47322 if(!p_igetw(&(m->undercombo),f))
47323 {
47324 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47325 }
47326
47327 if(!p_getc(&(m->undercset),f))
47328 {
47329 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47330 }
47331
47332 if(!p_igetw(&(m->catchall),f))
47333 {
47334 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47335 }
47336
47337 if(!p_getc(&(m->flags),f))
47338 {
47339 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47340 }
47341
47342 if(!p_getc(&(m->flags2),f))
47343 {
47344 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47345 }
47346
47347 if(!p_getc(&(m->flags3),f))
47348 {
47349 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47350 }
47351
47352 if(!p_getc(&(m->flags4),f))
47353 {
47354 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47355 }
47356
47357 if(!p_getc(&(m->flags5),f))
47358 {
47359 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47360 }
47361
47362 if(!p_igetw(&(m->noreset),f))
47363 {
47364 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47365 }
47366
47367 if(!p_igetw(&(m->nocarry),f))
47368 {
47369 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47370 }
47371
47372 if(!p_getc(&(m->flags6),f))
47373 {
47374 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47375 }
47376
47377 if(!p_getc(&(m->flags7),f))
47378 {
47379 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47380 }
47381
47382 if(!p_getc(&(m->flags8),f))
47383 {
47384 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47385 }
47386
47387 if(!p_getc(&(m->flags9),f))
47388 {
47389 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47390 }
47391
47392 if(!p_getc(&(m->flags10),f))
47393 {
47394 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47395 }
47396
47397 if(!p_getc(&(m->csensitive),f))
47398 {
47399 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47400 }
47401
47402 if(!p_getc(&(m->oceansfx),f))
47403 {
47404 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47405 }
47406
47407 if(!p_getc(&(m->bosssfx),f))
47408 {
47409 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47410 }
47411
47412 if(!p_getc(&(m->secretsfx),f))
47413 {
47414 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47415 }
47416
47417 if(!p_getc(&(m->holdupsfx),f))
47418 {
47419 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47420 }
47421
47422 for(int32_t k=0; k<6; k++)
47423 {
47424 if(!p_getc(&(m->layermap[k]),f))
47425 {
47426 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47427 }
47428 }
47429
47430 for(int32_t k=0; k<6; k++)
47431 {
47432 if(!p_getc(&(m->layerscreen[k]),f))
47433 {
47434 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47435 }
47436 }
47437
47438 for(int32_t k=0; k<6; k++)
47439 {
47440 if(!p_getc(&(m->layeropacity[k]),f))
47441 {
47442 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47443 }
47444 }
47445
47446 if(!p_igetw(&(m->timedwarptics),f))
47447 {
47448 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47449 }
47450
47451 if(!p_getc(&(m->nextmap),f))
47452 {
47453 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47454 }
47455
47456 if(!p_getc(&(m->nextscr),f))
47457 {
47458 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47459 }
47460
47461 for(int32_t k=0; k<128; k++)
47462 {
47463 if(!p_igetw(&(m->secretcombo[k]),f))
47464 {
47465 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47466 }
47467 }
47468
47469 for(int32_t k=0; k<128; k++)
47470 {
47471 if(!p_getc(&(m->secretcset[k]),f))
47472 {
47473 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47474 }
47475 }
47476
47477 for(int32_t k=0; k<128; k++)
47478 {
47479 if(!p_getc(&(m->secretflag[k]),f))
47480 {
47481 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47482 }
47483 }
47484
47485 for(int32_t k=0; k<(ZCMaps[i].tileWidth)*(ZCMaps[i].tileHeight); k++)
47486 {
47487 try
47488 {
47489 if(!p_igetw(&(m->data[k]),f))
47490 {
47491 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47492 }
47493 }
47494 catch(std::out_of_range& )
47495 {
47496 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47497 }
47498 }
47499
47500 for(int32_t k=0; k<(ZCMaps[i].tileWidth)*(ZCMaps[i].tileHeight); k++)
47501 {
47502 try
47503 {
47504 if(!p_getc(&(m->sflag[k]),f))
47505 {
47506 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47507 }
47508 }
47509 catch(std::out_of_range& )
47510 {
47511 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47512 }
47513 }
47514
47515 for(int32_t k=0; k<(ZCMaps[i].tileWidth)*(ZCMaps[i].tileHeight); k++)
47516 {
47517 try
47518 {
47519 if(!p_getc(&(m->cset[k]),f))
47520 {
47521 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47522 }
47523 }
47524 catch(std::out_of_range& )
47525 {
47526 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47527 }
47528 }
47529
47530 if(!p_igetw(&(m->screen_midi),f))
47531 {
47532 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47533 }
47534
47535 if(!p_getc(&(m->lens_layer),f))
47536 {
47537 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47538 }
47539 word tempw;
47540 for(int32_t k=0; k<32; k++)
47541 {
47542
47543 if(!p_igetw(&tempw,f))
47544 {
47545 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47546 }
47547 m->ffcs[k].setData(tempw);
47548
47549 if(!p_getc(&(m->ffcs[k].cset),f))
47550 {
47551 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47552 }
47553
47554 if(!p_igetw(&(m->ffcs[k].delay),f))
47555 {
47556 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47557 }
47558
47559 if(!p_igetzf(&(m->ffcs[k].x),f))
47560 {
47561 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47562 }
47563
47564 if(!p_igetzf(&(m->ffcs[k].y),f))
47565 {
47566 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47567 }
47568
47569 if(!p_igetzf(&(m->ffcs[k].vx),f))
47570 {
47571 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47572 }
47573
47574 if(!p_igetzf(&(m->ffcs[k].vy),f))
47575 {
47576 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47577 }
47578
47579 if(!p_igetzf(&(m->ffcs[k].ax),f))
47580 {
47581 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47582 }
47583
47584 if(!p_igetzf(&(m->ffcs[k].ay),f))
47585 {
47586 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47587 }
47588
47589 if(!p_getc(&(m->ffcs[k].link),f))
47590 {
47591 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47592 }
47593
47594 if(!p_igetl(&(m->ffcs[k].hit_width),f))
47595 {
47596 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47597 }
47598
47599 if(!p_igetl(&(m->ffcs[k].hit_height),f))
47600 {
47601 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47602 }
47603
47604 if(!p_getc(&(m->ffcs[k].txsz),f))
47605 {
47606 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47607 }
47608
47609 if(!p_getc(&(m->ffcs[k].tysz),f))
47610 {
47611 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47612 }
47613
47614 if(!p_igetl(&(m->ffcs[k].flags),f))
47615 {
47616 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47617 }
47618
47619 if(!p_igetw(&(m->ffcs[k].script),f))
47620 {
47621 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47622 }
47623
47624 if(!p_igetl(&(m->ffcs[k].initd[0]),f))
47625 {
47626 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47627 }
47628
47629 if(!p_igetl(&(m->ffcs[k].initd[1]),f))
47630 {
47631 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47632 }
47633
47634 if(!p_igetl(&(m->ffcs[k].initd[2]),f))
47635 {
47636 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47637 }
47638
47639 if(!p_igetl(&(m->ffcs[k].initd[3]),f))
47640 {
47641 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47642 }
47643
47644 if(!p_igetl(&(m->ffcs[k].initd[4]),f))
47645 {
47646 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47647 }
47648
47649 if(!p_igetl(&(m->ffcs[k].initd[5]),f))
47650 {
47651 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47652 }
47653
47654 if(!p_igetl(&(m->ffcs[k].initd[6]),f))
47655 {
47656 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47657 }
47658
47659 if(!p_igetl(&(m->ffcs[k].initd[7]),f))
47660 {
47661 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47662 }
47663
47664 }
47665
47666 for ( int32_t q = 0; q < 10; q++ )
47667 {
47668 if(!p_igetl(&(m->npcstrings[q]),f))
47669 {
47670 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47671 }
47672 }
47673 for ( int32_t q = 0; q < 10; q++ )
47674 {
47675 if(!p_igetw(&(m->new_items[q]),f))
47676 {
47677 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47678 }
47679 }
47680 for ( int32_t q = 0; q < 10; q++ )
47681 {
47682 if(!p_igetw(&(m->new_item_x[q]),f))
47683 {
47684 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47685 }
47686 }
47687 for ( int32_t q = 0; q < 10; q++ )
47688 {
47689 if(!p_igetw(&(m->new_item_y[q]),f))
47690 {
47691 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47692 }
47693 }
47694 if(!p_igetw(&(m->script),f))
47695 {
47696 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47697 }
47698 for ( int32_t q = 0; q < 8; q++ )
47699 {
47700 if(!p_igetl(&(m->screeninitd[q]),f))
47701 {
47702 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47703 }
47704
47705 }
47706 if(!p_getc(&(m->preloadscript),f))
47707 {
47708 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47709 }
47710
47711 if ( vers_id >= 2 )
47712 {
47713 if(!p_getc(&(m->hidelayers),f))
47714 {
47715 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47716 }
47717 if(!p_getc(&(m->hidescriptlayers),f))
47718 {
47719 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE\n"); return;
47720 }
47721
47722 }
47723
47724
47725 }//end mapscr all for loop
47726
47727 }
47728 }
47729 /*
47730 void FFScript::write_maps(PACKFILE *f, int32_t vers_id)
47731 {
47732 for(int32_t i=0; i<map_count && i<MAXMAPS2; i++)
47733 {
47734 for(int32_t j=0; j<MAPSCRS; j++)
47735 {
47736 if ( !(FFCore.write_mapscreen(f,i,j,vers_id)) )
47737 {
47738 Z_scripterrlog("do_savegamestructs FAILED to write MAPSCR NODE: %d",i*j);
47739 }
47740 }
47741 }
47742 }
47743
47744 void FFScript::read_maps(PACKFILE *f, int32_t vers_id)
47745 {
47746 for(int32_t i=0; i<map_count && i<MAXMAPS2; i++)
47747 {
47748 for(int32_t j=0; j<MAPSCRS; j++)
47749 {
47750 if ( !(FFCore.read_mapscreen(f,i,j,vers_id)) )
47751 {
47752 Z_scripterrlog("do_savegamestructs FAILED to read MAPSCR NODE: %d",i*j);
47753 }
47754 }
47755 }
47756 }
47757 */
47758
47759
47760 int32_t FFScript::getHeroOTile(int32_t index1, int32_t index2)
47761 {
47762 {
47763 herospritetype lst = (herospritetype)index1;
47764 int32_t dir = index2;
47765 int32_t the_ret = 0;
47766 switch(lst)
47767 {
47768 case LSprwalkspr: the_ret = walkspr[dir][0]; break;
47769 case LSprstabspr: the_ret = stabspr[dir][0]; break;
47770 case LSprslashspr: the_ret = slashspr[dir][0]; break;
47771 case LSprrevslashspr: the_ret = revslashspr[dir][0]; break;
47772 case LSprfloatspr: the_ret = floatspr[dir][0]; break;
47773 case LSprswimspr: the_ret = swimspr[dir][0]; break;
47774 case LSprdivespr: the_ret = divespr[dir][0]; break;
47775 case LSprdrownspr: the_ret = drowningspr[dir][0]; break;
47776 case LSprsidedrownspr: the_ret = sidedrowningspr[dir][0]; break;
47777 case LSprlavadrownspr: the_ret = drowning_lavaspr[dir][0]; break;
47778 case LSprsideswimspr: the_ret = sideswimspr[dir][0]; break;
47779 case LSprsideswimslashspr: the_ret = sideswimslashspr[dir][0]; break;
47780 case LSprsideswimstabspr: the_ret = sideswimstabspr[dir][0]; break;
47781 case LSprsideswimpoundspr: the_ret = sideswimpoundspr[dir][0]; break;
47782 case LSprsideswimchargespr: the_ret = sideswimchargespr[dir][0]; break;
47783 case LSprpoundspr: the_ret = poundspr[dir][0]; break;
47784 case LSprjumpspr: the_ret = jumpspr[dir][0]; break;
47785 case LSprchargespr: the_ret = chargespr[dir][0]; break;
47786 case LSprcastingspr: the_ret = castingspr[0]; break;
47787 case LSprsideswimcastingspr: the_ret = sideswimcastingspr[0]; break;
47788 case LSprholdspr1: the_ret = holdspr[0][0][0]; break;
47789 case LSprholdspr2: the_ret = holdspr[0][1][0]; break;
47790 case LSprholdsprw1: the_ret = holdspr[1][0][0]; break;
47791 case LSprholdsprw2: the_ret = holdspr[1][1][0]; break;
47792 case LSprholdsprSw1: the_ret = sideswimholdspr[0][0]; break;
47793 case LSprholdsprSw2: the_ret = sideswimholdspr[1][0]; break;
47794 default: the_ret = 0;
47795 }
47796
47797 return the_ret*10000;
47798 }
47799 }
47800
47801 defWpnSprite FFScript::getDefWeaponSprite(int32_t wpnid)
47802 {
47803 switch(wpnid)
47804 {
47805 case wNone: return ws_0;
47806 case wSword: return ws_0;
47807 case wBeam: return wsBeam;
47808 case wBrang : return wsBrang;
47809 case wBomb: return wsBomb;
47810 case wSBomb: return wsSBomb;
47811 case wLitBomb: return wsBombblast;
47812 case wLitSBomb: return wsBombblast;
47813 case wArrow: return wsArrow;
47814 case wFire: return wsFire;
47815 case wWhistle: return wsUnused45;
47816 case wBait: return wsBait;
47817 case wWand: return wsWandHandle;
47818 case wMagic: return wsMagic;
47819 case wCatching: return wsUnused45;
47820 case wWind: return wsWind;
47821 case wRefMagic: return wsRefMagic;
47822 case wRefFireball: return wsRefFireball;
47823 case wRefRock: return wsRock;
47824 case wHammer: return wsHammer;
47825 case wHookshot: return wsHookshotHead;
47826 case wHSHandle: return wsHookshotHandle;
47827 case wHSChain: return wsHookshotChainH;
47828 case wSSparkle: return wsSilverSparkle;
47829 case wFSparkle: return wsGoldSparkle;
47830 case wSmack: return wsHammerSmack;
47831 case wPhantom: return wsUnused45;
47832 case wCByrna: return wsByrnaCane;
47833 case wRefBeam: return wsRefBeam;
47834 case wStomp: return wsUnused45;
47835 case lwMax: return wsUnused45;
47836 case wScript1:
47837 case wScript2:
47838 case wScript3:
47839 case wScript4:
47840 case wScript5:
47841 case wScript6:
47842 case wScript7:
47843 case wScript8:
47844 case wScript9:
47845 case wScript10: return ws_0;
47846 case wIce: return wsIce; //new
47847 case wFlame: return wsEFire2; //new
47848 //not implemented; t/b/a
47849 case wSound:
47850 case wThrown:
47851 case wPot:
47852 case wLit:
47853 case wBombos:
47854 case wEther:
47855 case wQuake:
47856 case wSword180:
47857 case wSwordLA: return wsUnused45;
47858
47859 case ewFireball: return wsFireball2;
47860 case ewArrow: return wsEArrow;
47861 case ewBrang: return wsBrang;
47862 case ewSword: return wsEBeam;
47863 case ewRock: return wsRock;
47864 case ewMagic: return wsEMagic;
47865 case ewBomb: return wsEBomb;
47866 case ewSBomb: return wsESbomb;
47867 case ewLitBomb: return wsEBombblast;
47868 case ewLitSBomb: return wsESbombblast;
47869 case ewFireTrail: return wsEFiretrail;
47870 case ewFlame: return wsEFire;
47871 case ewWind: return wsEWind;
47872 case ewFlame2: return wsEFire2;
47873 case ewFlame2Trail: return wsEFiretrail2;
47874 case ewIce: return wsIce;
47875 case ewFireball2: return wsFireball2;
47876 default: return wsUnused45;
47877 }
47878 };
47879
47880
47881 12 int32_t FFScript::getEnemyByScriptUID(int32_t sUID)
47882 {
47883
47884
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 for(word i = 0; i < guys.Count(); i++)
47885 {
47886 27 enemy *w = (enemy*)guys.spr(i);
47887
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 15 times.
27 if ( w ->script_UID == sUID ) return i;
47888 15 }
47889 return -1;
47890 12 }
47891
47892 598 int32_t FFScript::getLWeaponByScriptUID(int32_t sUID)
47893 {
47894
47895
1/2
✓ Branch 0 taken 2168 times.
✗ Branch 1 not taken.
2168 for(word i = 0; i < Lwpns.Count(); i++)
47896 {
47897 2168 weapon *w = (weapon*)Lwpns.spr(i);
47898
2/2
✓ Branch 0 taken 598 times.
✓ Branch 1 taken 1570 times.
2168 if ( w ->script_UID == sUID ) return i;
47899 1570 }
47900 return -1;
47901 598 }
47902
47903 int32_t FFScript::getEWeaponByScriptUID(int32_t sUID)
47904 {
47905
47906 for(word i = 0; i < Ewpns.Count(); i++)
47907 {
47908 weapon *w = (weapon*)Ewpns.spr(i);
47909 if ( w ->script_UID == sUID ) return i;
47910 }
47911 return -1;
47912 }
47913
47914
47915 598 void FFScript::do_loadlweapon_by_script_uid(const bool v)
47916 {
47917 598 int32_t sUID = SH::get_arg(sarg1, v); //literal, not div by 10000
47918
47919 598 int32_t indx = FFCore.getLWeaponByScriptUID(sUID);
47920
1/2
✓ Branch 0 taken 598 times.
✗ Branch 1 not taken.
598 if ( indx > -1 )
47921 598 ri->lwpn = Lwpns.spr(indx)->getUID();
47922 else
47923 {
47924 ri->lwpn = 0;
47925 if(get_qr(qr_LOG_INVALID_UID_LOAD))
47926 Z_scripterrlog("There is no valid LWeapon associated with UID (%) at this time.\nThe UID is stale, or invalid.\n", sUID);
47927 }
47928 598 }
47929
47930 void FFScript::do_loadeweapon_by_script_uid(const bool v)
47931 {
47932
47933 int32_t sUID = SH::get_arg(sarg1, v); //literal, not div by 10000
47934
47935 int32_t indx = FFCore.getEWeaponByScriptUID(sUID);
47936 if ( indx > -1 )
47937 ri->ewpn = Ewpns.spr(indx)->getUID();
47938 else
47939 {
47940 ri->ewpn = 0;
47941 if(get_qr(qr_LOG_INVALID_UID_LOAD))
47942 Z_scripterrlog("There is no valid EWeapon associated with UID (%) at this time.\nThe UID is stale, or invalid.\n", sUID);
47943 }
47944 }
47945
47946
47947 12 void FFScript::do_loadnpc_by_script_uid(const bool v)
47948 {
47949
47950 12 int32_t sUID = SH::get_arg(sarg1, v); //literal, not div by 10000
47951
47952 12 int32_t indx = FFCore.getEnemyByScriptUID(sUID);
47953
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if ( indx > -1 )
47954 12 ri->guyref = guys.spr(indx)->getUID();
47955 else
47956 {
47957 ri->guyref = 0;
47958 if(get_qr(qr_LOG_INVALID_UID_LOAD))
47959 Z_scripterrlog("There is no valid NPC associated with UID (%) at this time.\nThe UID is stale, or invalid.\n", sUID);
47960 }
47961 12 }
47962
47963 //Combo Scripts
47964
47965 58860 void FFScript::clear_combo_scripts()
47966 {
47967 58860 memset(combo_id_cache, -1, sizeof(combo_id_cache));
47968 58860 clear_script_engine_data_of_type(ScriptType::Combo);
47969 58860 }
47970
47971 3018 void FFScript::clear_combo_script(int32_t lyr, int32_t pos)
47972 {
47973
1/2
✓ Branch 0 taken 3018 times.
✗ Branch 1 not taken.
3018 if(lyr < 0) return;
47974
47975
47976 3018 int32_t index = get_combopos_ref(pos, lyr);
47977
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3018 times.
3018 if (index >= 176*7) return;
47978
47979 3018 combo_id_cache[index] = -1;
47980 3018 combopos_modified = index;
47981 3018 clear_script_engine_data(ScriptType::Combo, index);
47982 3018 }
47983
47984 int32_t FFScript::getComboDataLayer(int32_t c, ScriptType scripttype)
47985 {
47986 if ( scripttype != ScriptType::Combo )
47987 {
47988 Z_scripterrlog("combodata->Layer() only runs from combo scripts, not from script type &s\n", ScriptTypeToString(scripttype));
47989 return -1;
47990 }
47991 else
47992 {
47993 int32_t l = 0;
47994 for (int32_t q = 176; q < 1232; q+= 176 )
47995 {
47996 if ( c < q )
47997 {
47998 return l;
47999 }
48000 ++l;
48001 }
48002 return -1;
48003 }
48004 }
48005
48006 int32_t FFScript::getCombodataPos(int32_t c, ScriptType scripttype)
48007 {
48008 if ( scripttype != ScriptType::Combo )
48009 {
48010 Z_scripterrlog("combodata->Pos() only runs from combo scripts, not from script type &s\n", ScriptTypeToString(scripttype));
48011 return -1;
48012 }
48013 else return ((c%176));
48014 }
48015
48016 int32_t FFScript::getCombodataX(int32_t c, ScriptType scripttype)
48017 {
48018 if ( scripttype != ScriptType::Combo )
48019 {
48020 Z_scripterrlog("combodata->X() only runs from combo scripts, not from script type &s\n", ScriptTypeToString(scripttype));
48021 return -1;
48022 }
48023 else
48024 {
48025 int32_t pos = getCombodataPos(c, scripttype);
48026 return COMBOX(pos);
48027 }
48028 }
48029
48030 int32_t FFScript::getCombodataY(int32_t c, ScriptType scripttype)
48031 {
48032 if ( scripttype != ScriptType::Combo )
48033 {
48034 Z_scripterrlog("combodata->Y() only runs from combo scripts, not from script type &s\n", ScriptTypeToString(scripttype));
48035 return -1;
48036 }
48037 else
48038 {
48039 int32_t pos = getCombodataPos(c, scripttype);
48040 return COMBOY(pos);
48041 }
48042 }
48043
48044 void FFScript::ClearComboScripts()
48045 {
48046 for ( int32_t c = 0; c < 176; c++ )
48047 {
48048 reset_script_engine_data(ScriptType::Combo, c);
48049 }
48050 }
48051
48052 627407 int32_t FFScript::combo_script_engine(const bool preload, const bool waitdraw)
48053 {
48054 ///non-scripted effects
48055
2/2
✓ Branch 0 taken 4391849 times.
✓ Branch 1 taken 627407 times.
5019256 for ( int32_t q = 0; q < 7; ++q )
48056 {
48057
2/2
✓ Branch 0 taken 558683 times.
✓ Branch 1 taken 3833166 times.
4391849 if (!get_qr(qr_COMBOSCRIPTS_LAYER_0+q))
48058 3833166 continue;
48059
2/2
✓ Branch 0 taken 98328208 times.
✓ Branch 1 taken 558683 times.
98886891 for ( int32_t c = 0; c < 176; ++c )
48060 {
48061 // int32_t ls = (q ? tmpscr->layerscreen[q-1] : 0);
48062 // int32_t lm = (q ? tmpscr->layermap[q-1] : 0);
48063 // if(q && !lm) continue; //No layer for this screen
48064 98328208 int32_t idval = get_combopos_ref(c, q);
48065 98328208 mapscr* m = FFCore.tempScreens[q]; //get templayer mapscr for any layer (including 0)
48066 98328208 word cid = m->data[c];
48067
1/2
✓ Branch 0 taken 98328208 times.
✗ Branch 1 not taken.
98328208 if(combo_id_cache[idval] < 0)
48068 combo_id_cache[idval] = cid;
48069
2/2
✓ Branch 0 taken 98167489 times.
✓ Branch 1 taken 160719 times.
98328208 else if(combo_id_cache[idval] != cid)
48070 {
48071 160719 combopos_modified = idval;
48072 160719 combo_id_cache[idval] = cid;
48073 160719 clear_script_engine_data(ScriptType::Combo, idval);
48074 160719 }
48075
48076
2/2
✓ Branch 0 taken 98204440 times.
✓ Branch 1 taken 123768 times.
98328208 if ( combobuf[cid].script )
48077 {
48078 123768 auto& data = get_script_engine_data(ScriptType::Combo, idval);
48079
2/2
✓ Branch 0 taken 47615 times.
✓ Branch 1 taken 76153 times.
123768 if (data.doscript)
48080 {
48081
3/4
✓ Branch 0 taken 38064 times.
✓ Branch 1 taken 38089 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38064 times.
76153 if (waitdraw && !data.waitdraw) continue;
48082
48083 38089 ZScriptVersion::RunScript(ScriptType::Combo, combobuf[cid].script, idval);
48084
1/2
✓ Branch 0 taken 38089 times.
✗ Branch 1 not taken.
38089 if (waitdraw) data.waitdraw = false;
48085 38089 }
48086 85704 }
48087 98290144 }
48088 558683 }
48089 627407 return 1;
48090 }
48091
48092 //Config for file->
48093
48094 /* ______ ___ ___
48095 * /\ _ \ /\_ \ /\_ \
48096 * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___
48097 * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\
48098 * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \
48099 * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
48100 * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/
48101 * /\____/
48102 * \_/__/
48103 *
48104 * Ported from Allegro 4.4.3.1 Configuration routines.
48105 *
48106 * By Shawn Hargreaves; C++ Port by ZoriaRPG
48107 *
48108 * Hook functions added by Martijn Versteegh.
48109 *
48110 * Annie Testes lifted several hardcoded length limitations.
48111 *
48112 * See readme.txt for copyright information.
48113 */
48114
48115
48116 #include "allegro.h"
48117 #include "allegro/internal/aintern.h"
48118
48119
48120
48121
48122
48123 /* zscript_flush_config:
48124 * Writes out a config structure to disk if the contents
48125 * have changed.
48126 */
48127 void zscript_flush_config(ZSCRIPT_CONFIG *cfg)
48128 {
48129 ZSCRIPT_CONFIG_ENTRY *pos;
48130 PACKFILE *f;
48131 char cr[16];
48132
48133 usetc(cr+usetc(cr, '\n'), 0);
48134
48135 if (cfg && cfg->filename && cfg->dirty)
48136 {
48137 /* write changed data to disk */
48138 f = pack_fopen(cfg->filename, F_WRITE);
48139
48140 if (f)
48141 {
48142 pos = cfg->head;
48143
48144 while (pos)
48145 {
48146 if (pos->name)
48147 {
48148 pack_fputs(pos->name, f);
48149
48150 if (ugetc(pos->name) != '[')
48151 {
48152 pack_putc(' ', f);
48153 pack_putc('=', f);
48154 pack_putc(' ', f);
48155 }
48156 }
48157
48158 if (pos->data)
48159 pack_fputs(pos->data, f);
48160
48161 pack_fputs(cr, f);
48162
48163 pos = pos->next;
48164 }
48165
48166 pack_fclose(f);
48167 cfg->dirty = FALSE;
48168 }
48169 }
48170 }
48171
48172
48173
48174 /* zscript_flush_config_file:
48175 * Writes out the config file to disk if the contents
48176 * have changed.
48177 */
48178 void zscript_flush_config_file(void)
48179 {
48180 zscript_flush_config(config[0]);
48181 }
48182
48183
48184
48185 /* zscript_destroy_config:
48186 * Destroys a config structure, writing it out to disk if the contents
48187 * have changed.
48188 */
48189 void zscript_destroy_config(ZSCRIPT_CONFIG *cfg)
48190 {
48191 ZSCRIPT_CONFIG_ENTRY *pos, *prev;
48192
48193 if (cfg)
48194 {
48195 zscript_flush_config(cfg);
48196
48197 if (cfg->filename)
48198 _AL_FREE(cfg->filename);
48199
48200 /* destroy the variable list */
48201 pos = cfg->head;
48202
48203 while (pos)
48204 {
48205 prev = pos;
48206 pos = pos->next;
48207
48208 if (prev->name)
48209 _AL_FREE(prev->name);
48210
48211 if (prev->data)
48212 _AL_FREE(prev->data);
48213
48214 _AL_FREE(prev);
48215 }
48216
48217 _AL_FREE(cfg);
48218 }
48219 }
48220
48221
48222
48223 /* zscript_config_cleanup:
48224 * Called at shutdown time to free memory being used by the config routines,
48225 * and write any changed data out to disk.
48226 */
48227 void zscript_config_cleanup(void)
48228 {
48229 ZSCRIPT_CONFIG_HOOK *hook, *nexthook;
48230 int32_t i;
48231
48232 for (i=0; i<MAX_CONFIGS; i++)
48233 {
48234 if (config[i])
48235 {
48236 zscript_destroy_config(config[i]);
48237 config[i] = NULL;
48238 }
48239 }
48240
48241 if (config_override)
48242 {
48243 zscript_destroy_config(config_override);
48244 config_override = NULL;
48245 }
48246
48247 if (config_language)
48248 {
48249 zscript_destroy_config(config_language);
48250 config_language = NULL;
48251 }
48252
48253 if (system_config)
48254 {
48255 zscript_destroy_config(system_config);
48256 system_config = NULL;
48257 }
48258
48259 if (config_hook)
48260 {
48261 hook = config_hook;
48262
48263 while (hook)
48264 {
48265 if (hook->section)
48266 _AL_FREE(hook->section);
48267
48268 nexthook = hook->next;
48269 _AL_FREE(hook);
48270 hook = nexthook;
48271 }
48272
48273 config_hook = NULL;
48274 }
48275
48276 _AL_FREE(config_argv);
48277 config_argv = NULL;
48278
48279 _AL_FREE(argv_buf);
48280 argv_buf = NULL;
48281
48282 argv_buf_size = 0;
48283
48284 _remove_exit_func(zscript_config_cleanup);
48285 config_installed = FALSE;
48286 }
48287
48288
48289
48290 /* zscript_init_config:
48291 * Sets up the configuration routines ready for use, also loading the
48292 * default config file if the loaddata flag is set and no other config
48293 * file is in memory.
48294 */
48295 void zscript_init_config(int32_t loaddata)
48296 {
48297 char filename[1024], tmp[128], *cfg_name;
48298
48299 if (!config_installed)
48300 {
48301 _add_exit_func(zscript_config_cleanup, "zscript_config_cleanup");
48302 config_installed = TRUE;
48303 }
48304
48305 if ((loaddata) && (!config[0]))
48306 {
48307 cfg_name = uconvert_ascii("allegro.cfg", tmp);
48308
48309 if (find_allegro_resource(filename, cfg_name, NULL, NULL, NULL, NULL, NULL, sizeof(filename)) != 0)
48310 {
48311 get_executable_name(filename, sizeof(filename));
48312 usetc(get_filename(filename), 0);
48313 ustrzcat(filename, sizeof(filename), cfg_name);
48314 }
48315
48316 zscript_set_config_file(filename);
48317 }
48318
48319 if (!system_config)
48320 {
48321 system_config = (struct ZSCRIPT_CONFIG*)malloc(sizeof(ZSCRIPT_CONFIG));
48322 if (system_config)
48323 {
48324 system_config->head = NULL;
48325 system_config->filename = NULL;
48326 system_config->dirty = FALSE;
48327 }
48328 }
48329 }
48330
48331
48332
48333 /* zscript_get_config_line:
48334 * Helper for splitting files up into individual lines. Returns the length
48335 * in bytes of the sequence of characters delimited by the first EOL marker
48336 * in the array DATA of length LENGTH, and allocates NAME and VAL to record
48337 * the name and the value of the config entry respectively; otherwise set
48338 * NAME to NULL and returns a copy of the line through VAL if the line was
48339 * blank or a comment. Returns -1 and set allegro_errno on failure.
48340 */
48341 int32_t zscript_get_config_line(const char *data, int32_t length, char **name, char **val)
48342 {
48343 char *buf;
48344 int32_t buf_size=256;
48345 int32_t inpos, outpos, i, j;
48346 int32_t c, c2, w0;
48347
48348 inpos = 0;
48349 outpos = 0;
48350 w0 = ucwidth(0);
48351
48352 buf = (char*)_AL_MALLOC_ATOMIC(buf_size);
48353 if (!buf)
48354 {
48355 *allegro_errno = ENOMEM;
48356 return -1;
48357 }
48358
48359 /* search for an EOL marker */
48360 while (inpos<length)
48361 {
48362 c = ugetc(data+inpos);
48363 if ((c == '\r') || (c == '\n'))
48364 {
48365 inpos += uwidth(data+inpos);
48366 if (inpos < length)
48367 {
48368 c2 = ugetc(data+inpos);
48369 if (((c == '\r') && (c2 == '\n')) || ((c == '\n') && (c2 == '\r')))
48370 inpos += uwidth(data+inpos);
48371 }
48372 break;
48373 }
48374
48375 /* increase the buffer size if needed */
48376 if (outpos>=(int32_t)buf_size-w0)
48377 {
48378 buf_size *= 2;
48379 buf = (char*)_al_sane_realloc(buf, buf_size);
48380 if (!buf)
48381 {
48382 *allegro_errno = ENOMEM;
48383 return -1;
48384 }
48385 }
48386
48387 outpos += usetc(buf+outpos, c);
48388 inpos += uwidth(data+inpos);
48389 }
48390
48391 usetc(buf+outpos, 0);
48392
48393 /* skip leading spaces */
48394 i = 0;
48395 c = ugetc(buf);
48396
48397 while ((c) && (uisspace(c)))
48398 {
48399 i += uwidth(buf+i);
48400 c = ugetc(buf+i);
48401 }
48402
48403 /* read name string */
48404 j = 0;
48405
48406 /* compute name length */
48407 while ((c) && (!uisspace(c)) && (c != '=') && (c != '#'))
48408 {
48409 j += ucwidth(c);
48410 i += uwidth(buf+i);
48411 c = ugetc(buf+i);
48412 }
48413
48414 if (j)
48415 {
48416 /* got a variable */
48417 *name = (char*)_AL_MALLOC_ATOMIC(j+w0);
48418 if (!(*name))
48419 {
48420 *allegro_errno = ENOMEM;
48421 _AL_FREE(buf);
48422 return -1;
48423 }
48424
48425 ustrzcpy(*name, j+w0, buf+i-j);
48426
48427 while ((c) && ((uisspace(c)) || (c == '=')))
48428 {
48429 i += uwidth(buf+i);
48430 c = ugetc(buf+i);
48431 }
48432
48433 *val = _al_ustrdup(buf+i);
48434 if (!(*val))
48435 {
48436 _AL_FREE(name);
48437 _AL_FREE(buf);
48438 return -1;
48439 }
48440
48441 /* strip trailing spaces */
48442 i = ustrlen(*val) - 1;
48443 while ((i >= 0) && (uisspace(ugetat(*val, i))))
48444 usetat(*val, i--, 0);
48445 }
48446 else
48447 {
48448 /* blank line or comment */
48449 *name = NULL;
48450 *val = _al_ustrdup(buf);
48451 if (!(*val))
48452 {
48453 _AL_FREE(buf);
48454 return -1;
48455 }
48456 }
48457
48458 _AL_FREE(buf);
48459
48460 return inpos;
48461 }
48462
48463
48464
48465 /* zscript_set_config:
48466 * Does the work of setting up a config structure.
48467 */
48468 void zscript_set_config(ZSCRIPT_CONFIG **config, const char *data, int32_t length, const char *filename)
48469 {
48470 ZSCRIPT_CONFIG_ENTRY **prev, *p;
48471 char *name, *val;
48472 int32_t ret, pos;
48473
48474 zscript_init_config(FALSE);
48475
48476 if (*config)
48477 {
48478 zscript_destroy_config(*config);
48479 *config = NULL;
48480 }
48481
48482 *config = (struct ZSCRIPT_CONFIG*)_AL_MALLOC(sizeof(ZSCRIPT_CONFIG));
48483 if (!(*config))
48484 {
48485 *allegro_errno = ENOMEM;
48486 return;
48487 }
48488
48489 (*config)->head = NULL;
48490 (*config)->dirty = FALSE;
48491
48492 if (filename)
48493 {
48494 (*config)->filename = _al_ustrdup(filename);
48495 if (!(*config)->filename)
48496 {
48497 _AL_FREE(*config);
48498 *config = NULL;
48499 return;
48500 }
48501 }
48502 else
48503 (*config)->filename = NULL;
48504
48505 prev = &(*config)->head;
48506 pos = 0;
48507
48508 while (pos < length)
48509 {
48510 ret = zscript_get_config_line(data+pos, length-pos, &name, &val);
48511 if (ret<0)
48512 {
48513 _AL_FREE(*config);
48514 *config = NULL;
48515 return;
48516 }
48517
48518 pos += ret;
48519
48520 p = (struct ZSCRIPT_CONFIG_ENTRY*)_AL_MALLOC(sizeof(ZSCRIPT_CONFIG_ENTRY));
48521 if (!p)
48522 {
48523 *allegro_errno = ENOMEM;
48524 _AL_FREE(*config);
48525 *config = NULL;
48526 return;
48527 }
48528
48529 p->name = name;
48530 p->data = val;
48531
48532 p->next = NULL;
48533 *prev = p;
48534 prev = &p->next;
48535 }
48536 }
48537
48538
48539
48540 /* zscript_load_config_file:
48541 * Does the work of loading a config file.
48542 */
48543 void zscript_load_config_file(ZSCRIPT_CONFIG **config, const char *filename, const char *savefile)
48544 {
48545 char *tmp, *tmp2;
48546 uint64_t length;
48547
48548 if (*config)
48549 {
48550 zscript_destroy_config(*config);
48551 *config = NULL;
48552 }
48553
48554 /* Special case when allegro_init has not been called yet. */
48555 if (!system_driver)
48556 {
48557 zscript_set_config(config, NULL, 0, savefile);
48558 return;
48559 }
48560
48561 length = file_size_ex(filename);
48562
48563 if (length > 0)
48564 {
48565 PACKFILE *f = pack_fopen(filename, F_READ);
48566
48567 if (f)
48568 {
48569 tmp = (char*)_AL_MALLOC_ATOMIC(length+1);
48570
48571 if (tmp)
48572 {
48573 pack_fread(tmp, length, f);
48574 tmp[length] = 0;
48575
48576 if (need_uconvert(tmp, U_UTF8, U_CURRENT))
48577 {
48578 length = uconvert_size(tmp, U_UTF8, U_CURRENT);
48579 tmp2 = (char*)_AL_MALLOC_ATOMIC(length);
48580
48581 if (tmp2)
48582 do_uconvert(tmp, U_UTF8, tmp2, U_CURRENT, length);
48583
48584 length -= ucwidth(0);
48585 }
48586 else
48587 tmp2 = tmp;
48588
48589 if (tmp2)
48590 {
48591 zscript_set_config(config, tmp2, length, savefile);
48592
48593 if (tmp2 != tmp)
48594 _AL_FREE(tmp2);
48595 }
48596
48597 _AL_FREE(tmp);
48598 }
48599 else
48600 zscript_set_config(config, NULL, 0, savefile);
48601
48602 pack_fclose(f);
48603 }
48604 else
48605 zscript_set_config(config, NULL, 0, savefile);
48606 }
48607 else
48608 zscript_set_config(config, NULL, 0, savefile);
48609 }
48610
48611
48612
48613 /* zscript_set_config_file:
48614 * Sets the file to be used for all future configuration operations.
48615 */
48616 void zscript_set_config_file(const char *filename)
48617 {
48618 ASSERT(filename);
48619 zscript_load_config_file(&config[0], filename, filename);
48620 }
48621
48622
48623
48624 /* zscript_set_config_data:
48625 * Sets the block of data to be used for all future configuration
48626 * operations.
48627 */
48628 void zscript_set_config_data(const char *data, int32_t length)
48629 {
48630 ASSERT(data);
48631 zscript_set_config(&config[0], data, length, NULL);
48632 }
48633
48634
48635
48636 /* zscript_override_config_file:
48637 * Sets the file that will override all future configuration operations.
48638 */
48639 void zscript_override_config_file(const char *filename)
48640 {
48641 /* load other configuration file to override settings */
48642 if (filename)
48643 zscript_load_config_file(&config_override, filename, filename);
48644 /* destroy the current one */
48645 else if (config_override)
48646 {
48647 zscript_destroy_config(config_override);
48648 config_override = NULL;
48649 }
48650 }
48651
48652
48653
48654 /* zscript_override_config_data:
48655 * Sets the block of data that will override all future configuration
48656 * operations.
48657 */
48658 void zscript_override_config_data(const char *data, int32_t length)
48659 {
48660 ASSERT(data);
48661 zscript_set_config(&config_override, data, length, NULL);
48662 }
48663
48664
48665
48666 /* zscript_push_config_state:
48667 * Pushes the current config state onto the stack.
48668 */
48669 void zscript_push_config_state(void)
48670 {
48671 int32_t i;
48672
48673 if (config[MAX_CONFIGS-1])
48674 zscript_destroy_config(config[MAX_CONFIGS-1]);
48675
48676 for (i=MAX_CONFIGS-1; i>0; i--)
48677 config[i] = config[i-1];
48678
48679 config[0] = NULL;
48680 }
48681
48682
48683
48684 /* zscript_pop_config_state:
48685 * Pops the current config state off the stack.
48686 */
48687 void zscript_pop_config_state(void)
48688 {
48689 int32_t i;
48690
48691 if (config[0])
48692 zscript_destroy_config(config[0]);
48693
48694 for (i=0; i<MAX_CONFIGS-1; i++)
48695 config[i] = config[i+1];
48696
48697 config[MAX_CONFIGS-1] = NULL;
48698 }
48699
48700
48701
48702 /* zscript_prettify_config_section_name:
48703 * Helper for ensuring that a section name is enclosed by [ ] braces.
48704 */
48705 void zscript_prettify_config_section_name(const char *in, char *out, int32_t out_size)
48706 {
48707 int32_t p;
48708
48709 if ((in) && (ustrlen(in)))
48710 {
48711 if (ugetc(in) != '[')
48712 {
48713 p = usetc(out, '[');
48714 usetc(out+p, 0);
48715 }
48716 else
48717 usetc(out, 0);
48718
48719 ustrzcat(out, out_size - ucwidth(']'), in);
48720
48721 out += uoffset(out, -1);
48722
48723 if (ugetc(out) != ']')
48724 {
48725 out += uwidth(out);
48726 out += usetc(out, ']');
48727 usetc(out, 0);
48728 }
48729 }
48730 else
48731 usetc(out, 0);
48732 }
48733
48734
48735
48736 /* zscript_hook_config_section:
48737 * Hooks a config section to a set of getter/setter functions. This will
48738 * override the normal table of values, and give the provider of the hooks
48739 * complete control over that section.
48740 */
48741 void zscript_hook_config_section(const char *section, int32_t (*intgetter)(const char *, int32_t), const char *(*stringgetter)(const char *, const char *), void (*stringsetter)(const char *, const char *))
48742 {
48743 ZSCRIPT_CONFIG_HOOK *hook, **prev;
48744 char section_name[256];
48745
48746 zscript_init_config(FALSE);
48747
48748 zscript_prettify_config_section_name(section, section_name, sizeof(section_name));
48749
48750 hook = config_hook;
48751 prev = &config_hook;
48752
48753 while (hook)
48754 {
48755 if (ustricmp(section_name, hook->section) == 0)
48756 {
48757 if ((intgetter) || (stringgetter) || (stringsetter))
48758 {
48759 /* modify existing hook */
48760 hook->intgetter = intgetter;
48761 hook->stringgetter = stringgetter;
48762 hook->stringsetter = stringsetter;
48763 }
48764 else
48765 {
48766 /* remove a hook */
48767 *prev = hook->next;
48768 _AL_FREE(hook->section);
48769 }
48770
48771 return;
48772 }
48773
48774 prev = &hook->next;
48775 hook = hook->next;
48776 }
48777
48778 /* add a new hook */
48779 hook = (struct ZSCRIPT_CONFIG_HOOK*)_AL_MALLOC(sizeof(ZSCRIPT_CONFIG_HOOK));
48780 if (!hook)
48781 return;
48782
48783 hook->section = _al_ustrdup(section_name);
48784 if (!(hook->section))
48785 {
48786 _AL_FREE(hook);
48787 return;
48788 }
48789
48790 hook->intgetter = intgetter;
48791 hook->stringgetter = stringgetter;
48792 hook->stringsetter = stringsetter;
48793
48794 hook->next = config_hook;
48795 config_hook = hook;
48796 }
48797
48798
48799
48800 /* is_config_hooked:
48801 * Checks whether a specific section is hooked in any way.
48802 */
48803 int32_t zscript_config_is_hooked(const char *section)
48804 {
48805 ZSCRIPT_CONFIG_HOOK *hook = config_hook;
48806 char section_name[256];
48807
48808 zscript_prettify_config_section_name(section, section_name, sizeof(section_name));
48809
48810 while (hook)
48811 {
48812 if (ustricmp(section_name, hook->section) == 0)
48813 return TRUE;
48814
48815 hook = hook->next;
48816 }
48817
48818 return FALSE;
48819 }
48820
48821
48822
48823 /* zscript_find_config_string:
48824 * Helper for finding an entry in the configuration file.
48825 */
48826 ZSCRIPT_CONFIG_ENTRY *zscript_find_config_string(ZSCRIPT_CONFIG *config, const char *section, const char *name, ZSCRIPT_CONFIG_ENTRY **prev)
48827 {
48828 ZSCRIPT_CONFIG_ENTRY *p;
48829 int32_t in_section;
48830
48831 if (config)
48832 {
48833 p = config->head;
48834
48835 if (prev)
48836 *prev = NULL;
48837
48838 if (section && ugetc(section))
48839 in_section = FALSE;
48840 else
48841 in_section = TRUE;
48842
48843 while (p)
48844 {
48845 if (p->name)
48846 {
48847 if ((section) && (ugetc(p->name) == '[') && (ugetat(p->name, -1) == ']'))
48848 {
48849 /* change section */
48850 in_section = (ustricmp(section, p->name) == 0);
48851 }
48852 if ((in_section) || (ugetc(name) == '['))
48853 {
48854 /* is this the one? */
48855 if (ustricmp(p->name, name) == 0)
48856 return p;
48857 }
48858 }
48859
48860 if (prev)
48861 *prev = p;
48862
48863 p = p->next;
48864 }
48865 }
48866
48867 return NULL;
48868 }
48869
48870
48871
48872 /* zscript_get_config_string:
48873 * Reads a string from the configuration file.
48874 */
48875 const char *zscript_get_config_string(const char *section, const char *name, const char *def)
48876 {
48877 char section_name[256];
48878 ZSCRIPT_CONFIG_HOOK *hook;
48879 ZSCRIPT_CONFIG_ENTRY *p;
48880
48881 zscript_init_config(TRUE);
48882
48883 zscript_prettify_config_section_name(section, section_name, sizeof(section_name));
48884
48885 /* check for hooked sections */
48886 hook = config_hook;
48887
48888 while (hook)
48889 {
48890 if (ustricmp(section_name, hook->section) == 0)
48891 {
48892 if (hook->stringgetter)
48893 return hook->stringgetter(name, def);
48894 else
48895 return def;
48896 }
48897 hook = hook->next;
48898 }
48899
48900 /* find the string */
48901 p = zscript_find_config_string(config_override, section_name, name, NULL);
48902
48903 if (!p)
48904 {
48905 if ((ugetc(name) == '#') || ((ugetc(section_name) == '[') && (ugetat(section_name, 1) == '#')))
48906 p = zscript_find_config_string(system_config, section_name, name, NULL);
48907 else
48908 p = zscript_find_config_string(config[0], section_name, name, NULL);
48909 }
48910
48911 if (p && p->data && (ustrlen(p->data) != 0))
48912 return p->data;
48913 else
48914 return def;
48915 }
48916
48917
48918
48919 /* zscript_get_config_int:
48920 * Reads an integer from the configuration file.
48921 */
48922 int32_t zscript_get_config_int(const char *section, const char *name, int32_t def)
48923 {
48924 ZSCRIPT_CONFIG_HOOK *hook;
48925 char section_name[256];
48926 const char *s;
48927
48928 zscript_prettify_config_section_name(section, section_name, sizeof(section_name));
48929
48930 /* check for hooked sections */
48931 hook = config_hook;
48932
48933 while (hook)
48934 {
48935 if (ustricmp(section_name, hook->section) == 0)
48936 {
48937 if (hook->intgetter)
48938 {
48939 return hook->intgetter(name, def);
48940 }
48941 else if (hook->stringgetter)
48942 {
48943 s = hook->stringgetter(name, NULL);
48944 if ((s) && (ugetc(s)))
48945 return ustrtol(s, NULL, 0);
48946 else
48947 return def;
48948 }
48949 else
48950 return def;
48951 }
48952 hook = hook->next;
48953 }
48954
48955 /* read normal data */
48956 s = zscript_get_config_string(section_name, name, NULL);
48957
48958 if ((s) && (ugetc(s)))
48959 return ustrtol(s, NULL, 0);
48960
48961 return def;
48962 }
48963
48964
48965
48966 /* zscript_get_config_hex:
48967 * Reads a hexadecimal integer from the configuration file.
48968 */
48969 int32_t zscript_get_config_hex(const char *section, const char *name, int32_t def)
48970 {
48971 const char *s = zscript_get_config_string(section, name, NULL);
48972 char tmp[64];
48973 int32_t i;
48974
48975 if ((s) && (ugetc(s)))
48976 {
48977 i = ustrtol(s, NULL, 16);
48978 if ((i == 0x7FFFFFFF) && (ustricmp(s, uconvert_ascii("7FFFFFFF", tmp)) != 0))
48979 i = -1;
48980 return i;
48981 }
48982
48983 return def;
48984 }
48985
48986
48987
48988 /* zscript_get_config_float:
48989 * Reads a float from the configuration file.
48990 */
48991 float zscript_get_config_float(const char *section, const char *name, float def)
48992 {
48993 const char* s = zscript_get_config_string(section, name, NULL);
48994
48995 if ((s) && (ugetc(s)))
48996 return uatof(s);
48997
48998 return def;
48999 }
49000
49001
49002
49003 /* zscript_get_config_id:
49004 * Reads a driver ID number from the configuration file.
49005 */
49006 int32_t zscript_get_config_id(const char *section, const char *name, int32_t def)
49007 {
49008 const char *s = zscript_get_config_string(section, name, NULL);
49009 char tmp[4];
49010 char* endp;
49011 int32_t val, i;
49012
49013 if ((s) && (ugetc(s)))
49014 {
49015 val = ustrtol(s, &endp, 0);
49016 if (!ugetc(endp))
49017 return val;
49018
49019 tmp[0] = tmp[1] = tmp[2] = tmp[3] = ' ';
49020
49021 for (i=0; i<4; i++)
49022 {
49023 if (ugetat(s, i))
49024 tmp[i] = utoupper(ugetat(s ,i));
49025 else
49026 break;
49027 }
49028
49029 return AL_ID(tmp[0], tmp[1], tmp[2], tmp[3]);
49030 }
49031
49032 return def;
49033 }
49034
49035
49036
49037 /* zscript_get_config_argv:
49038 * Reads an argc/argv style token list from the configuration file.
49039 */
49040 char **zscript_get_config_argv(const char *section, const char *name, int32_t *argc)
49041 {
49042 int32_t pos, ac, q, c;
49043 int32_t s_size;
49044 int32_t i;
49045
49046 const char *s = zscript_get_config_string(section, name, NULL);
49047
49048 if (!s)
49049 {
49050 *argc = 0;
49051 return NULL;
49052 }
49053
49054 /* clean up the old argv that was allocated the last time this function was
49055 * called.
49056 */
49057 _AL_FREE(config_argv);
49058 config_argv = NULL;
49059
49060 /* increase the buffer size if needed */
49061 s_size = ustrsizez(s);
49062 if (s_size>argv_buf_size)
49063 {
49064 argv_buf_size = s_size;
49065 argv_buf = (char*)_al_sane_realloc(argv_buf, argv_buf_size);
49066 if (!argv_buf)
49067 {
49068 *allegro_errno = ENOMEM;
49069 *argc = 0;
49070 return NULL;
49071 }
49072 }
49073
49074 ustrzcpy(argv_buf, argv_buf_size, s);
49075 pos = 0;
49076 ac = 0;
49077
49078 /* tokenize the buffer and count the number of words; every space character
49079 * as well as single and double quotes are replaced with zeros; comments * that start with # are also cut off with a 0
49080 */
49081 c = ugetc(argv_buf);
49082 while ((c) && (c != '#'))
49083 {
49084 /* replace all spaces up to the next word with 0 */
49085 while ((c) && (uisspace(c)))
49086 {
49087 usetat(argv_buf+pos, 0, 0);
49088 pos += ucwidth(0);
49089 c = ugetc(argv_buf+pos);
49090 }
49091
49092 /* quit if we reached the end of the buffer or a comment */
49093 if ((c) && (c != '#'))
49094 {
49095 /* found another word! */
49096 ac++;
49097
49098 /* cut away quotes by replacing them with 0 */
49099 if ((c == '\'') || (c == '"'))
49100 {
49101 q = c;
49102 usetat(argv_buf+pos, 0, 0);
49103 pos += ucwidth(0);
49104 c = ugetc(argv_buf+pos);
49105 }
49106 else
49107 {
49108 q = 0;
49109 }
49110
49111 /* search for the end of the word */
49112 while ((c) && ((q) ? (c != q) : (!uisspace(c))))
49113 {
49114 pos += ucwidth(c);
49115 c = ugetc(argv_buf+pos);
49116 }
49117 }
49118 }
49119
49120 /* now that we know how many words there are in the buffer, allocate enough
49121 * space for a list of pointers to them, or return 0 if there are no words
49122 */
49123 if (ac > 0)
49124 {
49125 config_argv = (char**)_AL_MALLOC(ac*sizeof *config_argv);
49126 }
49127 else
49128 {
49129 *argc = 0;
49130 return NULL;
49131 }
49132
49133 /* go through the tokenized buffer and assign pointers in argv to point to
49134 * the beginning of each individual word
49135 */
49136 for (i=0,pos=0,c=ugetc(argv_buf); i<ac; i++)
49137 {
49138 /* find next word */
49139 while (!c)
49140 {
49141 pos += ucwidth(c);
49142 c = ugetc(argv_buf+pos);
49143 }
49144
49145 /* assign pointer */
49146 config_argv[i] = argv_buf+pos;
49147
49148 /* find end of the word */
49149 while (c)
49150 {
49151 pos += ucwidth(c);
49152 c = ugetc(argv_buf+pos);
49153 }
49154 }
49155
49156 *argc = ac;
49157 return config_argv;
49158 }
49159
49160
49161
49162 /* zscript_insert_config_variable:
49163 * Helper for inserting a new variable into a configuration file.
49164 */
49165 ZSCRIPT_CONFIG_ENTRY *zscript_insert_config_variable(ZSCRIPT_CONFIG *the_config, ZSCRIPT_CONFIG_ENTRY *p, const char *name, const char *data)
49166 {
49167 ZSCRIPT_CONFIG_ENTRY *n = (struct ZSCRIPT_CONFIG_ENTRY*)_AL_MALLOC(sizeof(ZSCRIPT_CONFIG_ENTRY));
49168
49169 if (!n)
49170 return NULL;
49171
49172 if (name)
49173 n->name = _al_ustrdup(name);
49174 else
49175 n->name = NULL;
49176
49177 if (data)
49178 n->data = _al_ustrdup(data);
49179 else
49180 n->data = NULL;
49181
49182 if (p)
49183 {
49184 n->next = p->next;
49185 p->next = n;
49186 }
49187 else
49188 {
49189 n->next = NULL;
49190 the_config->head = n;
49191 }
49192
49193 return n;
49194 }
49195
49196
49197
49198 /* zscript_set_config_string:
49199 * Writes a string to the configuration file.
49200 */
49201 void zscript_set_config_string(const char *section, const char *name, const char *val)
49202 {
49203 ZSCRIPT_CONFIG *the_config;
49204 ZSCRIPT_CONFIG_HOOK *hook;
49205 ZSCRIPT_CONFIG_ENTRY *p, *prev;
49206 char section_name[256];
49207
49208 zscript_init_config(TRUE);
49209
49210 zscript_prettify_config_section_name(section, section_name, sizeof(section_name));
49211
49212 /* check for hooked sections */
49213 hook = config_hook;
49214
49215 while (hook)
49216 {
49217 if (ustricmp(section_name, hook->section) == 0)
49218 {
49219 if (hook->stringsetter)
49220 hook->stringsetter(name, val);
49221 return;
49222 }
49223 hook = hook->next;
49224 }
49225
49226 /* decide which config file to use */
49227 if ((ugetc(name) == '#') || ((ugetc(section_name) == '[') && (ugetat(section_name, 1) == '#')))
49228 the_config = system_config;
49229 else if (config_override)
49230 the_config = config_override;
49231 else
49232 the_config = config[0];
49233
49234 if (the_config)
49235 {
49236 p = zscript_find_config_string(the_config, section_name, name, &prev);
49237
49238 if (p)
49239 {
49240 if ((val) && (ugetc(val)))
49241 {
49242 /* modify existing variable */
49243 if (p->data)
49244 _AL_FREE(p->data);
49245
49246 p->data = _al_ustrdup(val);
49247 }
49248 else
49249 {
49250 /* delete variable */
49251 if (p->name)
49252 _AL_FREE(p->name);
49253
49254 if (p->data)
49255 _AL_FREE(p->data);
49256
49257 if (prev)
49258 prev->next = p->next;
49259 else
49260 the_config->head = p->next;
49261
49262 _AL_FREE(p);
49263 }
49264 }
49265 else
49266 {
49267 if ((val) && (ugetc(val)))
49268 {
49269 /* add a new variable */
49270 if (ugetc(section_name))
49271 {
49272 p = zscript_find_config_string(the_config, NULL, section_name, &prev);
49273
49274 if (!p)
49275 {
49276 /* create a new section */
49277 p = the_config->head;
49278 while ((p) && (p->next))
49279 p = p->next;
49280
49281 if ((p) && (p->data) && (ugetc(p->data)))
49282 p = zscript_insert_config_variable(the_config, p, NULL, NULL);
49283
49284 p = zscript_insert_config_variable(the_config, p, section_name, NULL);
49285 }
49286
49287 /* append to the end of the section */
49288 while ((p) && (p->next) &&
49289 (((p->next->name) && (ugetc(p->next->name))) ||
49290 ((p->next->data) && (ugetc(p->next->data)))))
49291 {
49292 p = p->next;
49293 }
49294
49295 p = zscript_insert_config_variable(the_config, p, name, val);
49296 }
49297 else
49298 {
49299 /* global variable */
49300 p = the_config->head;
49301 zscript_insert_config_variable(the_config, NULL, name, val);
49302 the_config->head->next = p;
49303 }
49304 }
49305 }
49306
49307 the_config->dirty = TRUE;
49308 }
49309 }
49310
49311
49312
49313 /* zscript_set_config_int:
49314 * Writes an integer to the configuration file.
49315 */
49316 void zscript_set_config_int(const char *section, const char *name, int32_t val)
49317 {
49318 char buf[32], tmp[32];
49319 uszprintf(buf, sizeof(buf), uconvert_ascii("%d", tmp), val);
49320 zscript_set_config_string(section, name, buf);
49321 }
49322
49323
49324
49325 /* zscript_set_config_hex:
49326 * Writes a hexadecimal integer to the configuration file.
49327 */
49328 void zscript_set_config_hex(const char *section, const char *name, int32_t val)
49329 {
49330 char buf[32], tmp[32];
49331
49332 if (val >= 0)
49333 {
49334 uszprintf(buf, sizeof(buf), uconvert_ascii("%X", tmp), val);
49335 zscript_set_config_string(section, name, buf);
49336 }
49337 else
49338 zscript_set_config_string(section, name, uconvert_ascii("-1", buf));
49339 }
49340
49341
49342
49343 /* zscript_set_config_float:
49344 * Writes a float to the configuration file.
49345 */
49346 void zscript_set_config_float(const char *section, const char *name, float val)
49347 {
49348 char buf[32], tmp[32];
49349 uszprintf(buf, sizeof(buf), uconvert_ascii("%f", tmp), val);
49350 zscript_set_config_string(section, name, buf);
49351 }
49352
49353
49354
49355 /* zscript_set_config_id:
49356 * Writes a driver ID to the configuration file.
49357 */
49358 void zscript_set_config_id(const char *section, const char *name, int32_t val)
49359 {
49360 char buf[32], tmp[32];
49361 int32_t v[4];
49362 int32_t pos = 0;
49363 int32_t i;
49364
49365 if (val < 256)
49366 {
49367 uszprintf(buf, sizeof(buf), uconvert_ascii("%d", tmp), val);
49368 }
49369 else
49370 {
49371 v[0] = (val>>24)&0xFF;
49372 v[1] = (val>>16)&0xFF;
49373 v[2] = (val>>8)&0xFF;
49374 v[3] = val&0xFF;
49375
49376 for (i=0; (i<4) && (v[i]) && (v[i] != ' '); i++)
49377 pos += usetc(buf+pos, v[i]);
49378
49379 usetc(buf+pos, 0);
49380 }
49381
49382 zscript_set_config_string(section, name, buf);
49383 }
49384
49385
49386
49387 /* _zscript_reload_config:
49388 * Internal helper to reload the configuration from allegro_init, in case
49389 * zscript_set_config_file was called before allegro_init.
49390 */
49391 void _zscript_reload_config(void)
49392 {
49393 if (config[0])
49394 {
49395 char *name = _al_ustrdup(config[0]->filename);
49396 zscript_set_config_file(name);
49397 _AL_FREE(name);
49398 }
49399 }
49400
49401
49402
49403 /* zscript_reload_config_texts:
49404 * Reads in a block of translated system text, looking for either a
49405 * user-specified file, a ??text.cfg file, or a language.dat#??TEXT_CFG
49406 * datafile object. If new_language is not NULL, the language config
49407 * variable will be set to new_language before reloading the
49408 * configuration files.
49409 */
49410 void zscript_reload_config_texts(const char *new_language)
49411 {
49412 char filename[1024], tmp1[128], tmp2[128];
49413 const char *name, *ext, *datafile;
49414 char *namecpy;
49415
49416 if (config_language)
49417 {
49418 zscript_destroy_config(config_language);
49419 config_language = NULL;
49420 }
49421
49422 if (new_language)
49423 zscript_set_config_string("system", "language", new_language);
49424
49425 name = zscript_get_config_string(uconvert_ascii("system", tmp1), uconvert_ascii("language", tmp2), NULL);
49426
49427 if ((name) && (ugetc(name)))
49428 {
49429 namecpy = _al_ustrdup(name);
49430 ustrlwr (namecpy);
49431 if ((ustrlen(namecpy)<4) || (ustricmp(namecpy+uoffset(namecpy, -4), uconvert_ascii("text", tmp1)) != 0))
49432 ext = uconvert_ascii("text.cfg", tmp1);
49433 else
49434 ext = uconvert_ascii(".cfg", tmp1);
49435
49436 datafile = uconvert_ascii("language.dat", tmp2);
49437
49438 if (find_allegro_resource(filename, namecpy, ext, datafile, NULL, NULL, NULL, sizeof(filename)) == 0)
49439 {
49440 _AL_FREE(namecpy);
49441 zscript_load_config_file(&config_language, filename, NULL);
49442 return;
49443 }
49444
49445 _AL_FREE(namecpy);
49446 }
49447
49448 config_language = (struct ZSCRIPT_CONFIG*)_AL_MALLOC(sizeof(ZSCRIPT_CONFIG));
49449 if (config_language )
49450 {
49451 config_language ->head = NULL;
49452 config_language ->filename = NULL;
49453 config_language ->dirty = FALSE;
49454 }
49455 }
49456
49457
49458
49459 /* zscript_get_config_text:
49460 * Looks up a translated version of the specified English string,
49461 * returning a suitable message in the current language if one is
49462 * available, or a copy of the parameter if no translation can be found.
49463 */
49464 const char *zscript_get_config_text(const char *msg)
49465 {
49466 char tmp1[256];
49467 const char *section;
49468 const char *umsg;
49469 const char *s;
49470 const char *ret = NULL;
49471 char *name;
49472 ZSCRIPT_CONFIG_HOOK *hook;
49473 ZSCRIPT_CONFIG_ENTRY *p;
49474 int32_t c, pos, size;
49475 ASSERT(msg);
49476
49477 /* Hack: the inline definition of install_allegro() from 4.2.0 calls
49478 * zscript_get_config_text() even before Allegro has been initialised, leading
49479 * to a crash in get_executable_name(). To retain binary compatibility
49480 * we check for this case.
49481 */
49482 if (_allegro_count == 0)
49483 {
49484 return msg;
49485 }
49486
49487 zscript_init_config(TRUE);
49488
49489 section = uconvert_ascii("[language]", tmp1);
49490
49491 /* allocate memory and convert message to current encoding format */
49492 if (need_uconvert(msg, U_ASCII, U_CURRENT))
49493 {
49494 size = uconvert_size(msg, U_ASCII, U_CURRENT);
49495 umsg = (char*)_AL_MALLOC_ATOMIC(size);
49496 if (!umsg)
49497 {
49498 *allegro_errno = ENOMEM;
49499 return empty_string;
49500 }
49501
49502 name = (char*)_AL_MALLOC_ATOMIC(size);
49503 if (!name)
49504 {
49505 _AL_FREE((char *)umsg); /* remove constness */
49506 *allegro_errno = ENOMEM;
49507 return empty_string;
49508 }
49509
49510 do_uconvert(msg, U_ASCII, (char*)umsg, U_CURRENT, size);
49511 }
49512 else
49513 {
49514 umsg = msg;
49515 name = (char*)_AL_MALLOC_ATOMIC(ustrsizez(msg));
49516 if (!name)
49517 {
49518 *allegro_errno = ENOMEM;
49519 return empty_string;
49520 }
49521 }
49522
49523 s = umsg;
49524 pos = 0;
49525
49526 while ((c = ugetxc(&s)) != 0)
49527 {
49528 if ((uisspace(c)) || (c == '=') || (c == '#'))
49529 pos += usetc(name+pos, '_');
49530 else
49531 pos += usetc(name+pos, c);
49532 }
49533
49534 usetc(name+pos, 0);
49535
49536 /* check for hooked sections */
49537 hook = config_hook;
49538
49539 while (hook)
49540 {
49541 if (ustricmp(section, hook->section) == 0)
49542 {
49543 if (hook->stringgetter)
49544 {
49545 ret = hook->stringgetter(name, umsg);
49546 break;
49547 }
49548 }
49549
49550 hook = hook->next;
49551 }
49552
49553 if (!ret)
49554 {
49555 /* find the string */
49556 p = zscript_find_config_string(config_override, section, name, NULL);
49557
49558 if (!p)
49559 {
49560 p = zscript_find_config_string(config[0], section, name, NULL);
49561
49562 if (!p)
49563 p = zscript_find_config_string(config_language, section, name, NULL);
49564 }
49565
49566 if (p)
49567 {
49568 ret = (p->data ? p->data : empty_string);
49569 }
49570 else
49571 {
49572 /* no translation, so store off this value in the file */
49573 p = config_language->head;
49574 zscript_insert_config_variable(config_language, NULL, name, umsg);
49575 config_language->head->next = p;
49576 ret = config_language->head->data;
49577 }
49578 }
49579
49580 /* free memory */
49581 if (umsg!=msg)
49582 _AL_FREE((char*) umsg); /* remove constness */
49583
49584 _AL_FREE(name);
49585
49586 return ret;
49587 }
49588
49589
49590
49591 /* zscript_add_unique_config_name
49592 * Helper to add a name to a list of names.
49593 */
49594 int32_t zscript_add_unique_config_name(const char ***names, int32_t n, char const *name)
49595 {
49596 int32_t i;
49597 /* FIXME: use better search algorithm */
49598 for (i = 0; i < n; i++)
49599 if (!ustrcmp((*names)[i], name))
49600 return n;
49601
49602 *names = (const char**)_al_sane_realloc((void *)*names, (n + 1) * sizeof **names);
49603 (*names)[n] = name;
49604 return n + 1;
49605 }
49606
49607
49608
49609 /* zscript_attach_config_entries
49610 * Helper function to attach key or section names to a list of strings.
49611 */
49612 int32_t zscript_attach_config_entries(ZSCRIPT_CONFIG *conf, const char *section, int32_t n, const char ***names, int32_t list_sections)
49613 {
49614 ZSCRIPT_CONFIG_ENTRY *p;
49615 char section_name[256];
49616 int32_t in_section;
49617
49618 zscript_prettify_config_section_name(section, section_name, sizeof(section_name));
49619
49620 if (conf)
49621 {
49622 p = conf->head;
49623
49624 /* If section is NULL, only initial, section-less entries are used. */
49625 if (ugetc(section_name))
49626 in_section = FALSE;
49627 else
49628 in_section = TRUE;
49629
49630 while (p)
49631 {
49632 if (p->name)
49633 {
49634 /* a section start is just a list entry enclosed in [] */
49635 if (ugetc(p->name) == '[' && ugetat(p->name, -1) == ']')
49636 {
49637 if (list_sections)
49638 {
49639 n = zscript_add_unique_config_name(names, n, p->name);
49640 }
49641 in_section = (ustricmp(section_name, p->name) == 0);
49642 }
49643 else if (in_section && !list_sections)
49644 {
49645 n = zscript_add_unique_config_name(names, n, p->name);
49646 }
49647 }
49648 p = p->next;
49649 }
49650 }
49651 return n;
49652 }
49653
49654
49655
49656 /* list_config_entires:
49657 * Returns the names of all config entries in a section. The names parameter is
49658 * a pointer to a strings array that will contain the config keys. If it points to
49659 * a NULL pointer, it will be allocated, or else re-allocated accordingly. The
49660 * return value tells how many valid string pointers it contains after the
49661 * function returns.
49662 */
49663 int32_t zscript_list_config_entries(const char *section, const char ***names)
49664 {
49665 int32_t n = 0;
49666 n = zscript_attach_config_entries(config_override, section, n, names, 0);
49667 n = zscript_attach_config_entries(config[0], section, n, names, 0);
49668 return n;
49669 }
49670
49671
49672
49673 /* zscript_list_config_sections:
49674 * Returns the names of all current config sections, enclodes in []. The names
49675 * parameter and return value is like in list_config_entires above.
49676 */
49677 int32_t zscript_list_config_sections(const char ***names)
49678 {
49679 int32_t n = 0;
49680 n = zscript_attach_config_entries(config_override, NULL, n, names, 1);
49681 n = zscript_attach_config_entries(config[0], NULL, n, names, 1);
49682 return n;
49683 }
49684
49685
49686
49687 /* zscript_free_config_entries:
49688 * Frees the entries list returned by list_config_entires or
49689 * zscript_list_config_sections again.
49690 */
49691 void zscript_free_config_entries(const char ***names)
49692 {
49693 _AL_FREE(*names);
49694 *names = NULL;
49695 }
49696
49697 225833 int32_t FFScript::Distance(double x1, double y1, double x2, double y2)
49698 {
49699 225833 double x = (x1-x2);
49700 225833 double y = (y1-y2);
49701 225833 double sum = (x*x)+(y*y);
49702 //if(((int32_t)sum) < 0)
49703 //{
49704 // Z_scripterrlog("Distance() attempted to calculate square root of %ld!\n", ((int32_t)sum));
49705 // return -10000;;
49706 //}
49707 225833 sum *= 1000000.0;
49708 225833 double total = sqrt(sum)*10;
49709 225833 return int32_t(total);
49710 }
49711
49712 int32_t FFScript::Distance(double x1, double y1, double x2, double y2, int32_t scale)
49713 {
49714 double x3 = x1+(x2-x1)/scale;
49715 double y3 = y1+(y2-y1)/scale;
49716 //double sum = (x*x)+(y*y);
49717 //if(((int32_t)sum) < 0)
49718 //{
49719 // Z_scripterrlog("Distance() attempted to calculate square root of %ld!\n", ((int32_t)sum));
49720 // return -10000;
49721 //}
49722 //sum *= 1000000.0;
49723 //double total = sqrt(sum)*10;
49724 //return int32_t(total*scale);
49725 return (FFCore.Distance(x1, y1, x3, y3)*scale);
49726 }
49727
49728 int32_t FFScript::LongDistance(double x1, double y1, double x2, double y2)
49729 {
49730 double x = (x1-x2);
49731 double y = (y1-y2);
49732 double sum = (x*x)+(y*y);
49733 //if(((int32_t)sum) < 0)
49734 //{
49735 // Z_scripterrlog("Distance() attempted to calculate square root of %ld!\n", ((int32_t)sum));
49736 // return -10000;;
49737 //}
49738 double total = sqrt(sum);
49739 return int32_t(total);
49740 }
49741
49742 int32_t FFScript::LongDistance(double x1, double y1, double x2, double y2, int32_t scale)
49743 {
49744 double x3 = x1+(x2-x1)/scale;
49745 double y3 = y1+(y2-y1)/scale;
49746 //double sum = (x*x)+(y*y);
49747 //if(((int32_t)sum) < 0)
49748 //{
49749 // Z_scripterrlog("Distance() attempted to calculate square root of %ld!\n", ((int32_t)sum));
49750 // return -10000;
49751 //}
49752 //sum *= 1000000.0;
49753 //double total = sqrt(sum)*10;
49754 //return int32_t(total*scale);
49755 return (FFCore.LongDistance(x1, y1, x3, y3)*scale);
49756 }
49757
49758 void FFScript::do_distance()
49759 {
49760 double x1 = double(ri->d[rSFTEMP] / 10000.0);
49761 double x2 = double(ri->d[rINDEX] / 10000.0);
49762 double y1 = double(ri->d[rINDEX2] / 10000.0);
49763 double y2 = double(ri->d[rEXP1] / 10000.0);
49764
49765 int32_t result = FFCore.Distance(x1, x2, y1, y2);
49766 //ret = result*10000;
49767
49768 }
49769
49770 40324293 bool command_is_wait(int command)
49771 {
49772
2/2
✓ Branch 0 taken 40319495 times.
✓ Branch 1 taken 4798 times.
40324293 switch (command)
49773 {
49774 case WAITFRAME:
49775 case WAITDRAW:
49776 case WAITTO:
49777 case WAITEVENT:
49778 case WAITFRAMESR:
49779 4798 return true;
49780 }
49781 40319495 return false;
49782 40324293 }
49783
49784 40322682 bool command_uses_comparison_result(int command)
49785 {
49786
2/2
✓ Branch 0 taken 1119540 times.
✓ Branch 1 taken 39203142 times.
40322682 switch (command)
49787 {
49788 case GOTOTRUE:
49789 case GOTOFALSE:
49790 case GOTOMORE:
49791 case GOTOLESS:
49792 case SETTRUE:
49793 case SETTRUEI:
49794 case SETFALSE:
49795 case SETFALSEI:
49796 case SETMOREI:
49797 case SETLESSI:
49798 case SETMORE:
49799 case SETLESS:
49800 1119540 return true;
49801 }
49802 39203142 return false;
49803 40322682 }
49804
49805 486351 bool command_could_return_not_ok(int command)
49806 {
49807
2/2
✓ Branch 0 taken 1507 times.
✓ Branch 1 taken 484844 times.
486351 switch (command)
49808 {
49809 case 0xFFFF:
49810 case EWPNDEL:
49811 case GAMECONTINUE:
49812 case GAMEEND:
49813 case GAMERELOAD:
49814 case GAMESAVECONTINUE:
49815 case GAMESAVEQUIT:
49816 case ITEMDEL:
49817 case LWPNDEL:
49818 case NPCKICKBUCKET:
49819 case SETSCREENDOOR:
49820 case SETSCREENENEMY:
49821 1507 return true;
49822 }
49823 484844 return false;
49824 486351 }
49825
49826 const script_command& get_script_command(int command)
49827 {
49828 return ZASMcommands[command];
49829 }
49830
49831 98337988 int32_t get_combopos_ref(int32_t pos, int32_t layer)
49832 {
49833 98337988 return layer * 176 + pos;
49834 }
49835
49836 94370 int32_t combopos_ref_to_pos(int32_t combopos_ref)
49837 {
49838 94370 return combopos_ref % 176;
49839 }
49840
49841 38089 int32_t combopos_ref_to_layer(int32_t combopos_ref)
49842 {
49843 38089 return combopos_ref / 176;
49844 }
49845